PowerShell:- File System – FileInfo

Background Determining whether a file is empty could involve a few application logic-specific steps or more generic API calls. Here is a sample code in Powershell.   Script Outline Command Line Arguments file Sanitize Variables file If the file is not specified, raise an exception Exception Type:- System.ArgumentNullException If the specified file does not exist, … Continue reading PowerShell:- File System – FileInfo

PowerShell:- File System – Create new file

Background I need to generate data files on a scheduled basis. The file's name should reflect the current time.   Script Outline Command Line Arguments folder filenamePrefix filenameSuffix fileExt fileTemplate Sanitize Variables folder If the folder is not specified, use the current folder Use Get-Location command Sanitize folder Make sure that it is not a … Continue reading PowerShell:- File System – Create new file

PowerShell – Using Pipeline Functions

Background In its design, Powershell offers a very elegant mechanism for pipeline handling. For instance, often in software development, we will need to process sets. Outline Function :- showFileContent Parameters ValueFromPipeline $filename Declare Local Variables [int] $rc = 0; [string] $filenameFullName = $null; [string] $filenameLeaf = $null; Process Increment script variable $fileNumber ( $script:fileNumber ) … Continue reading PowerShell – Using Pipeline Functions