PowerShell
- 07 March
Compare Contents of Two Folders in PowerShell
Comparing Contents of Two Folders in PowerSHell PowerShell is a powerful tool that can help system administrators and IT professionals automate routine tasks, and one of the common tasks is comparing the contents of two folders. This can be useful for identifying differences between two directory versions or finding missing files in a backup. To […]
- 20 February
Print Blank Line in PowerShell
Print Blank Line in PowerShell We have two string-type messages that we want to print on the PowerShell console, but in between, we also want to have a blank line to increase the readability. For instance, we want to get results as follows: [crayon-679095fd4ef15670735214/] To do as demonstrated above, we can use different ways. Let’s […]
- 14 February
How to Run ps1 File from PowerShell
Running from PowerShell Command-Line To run a PowerShell script(.ps1 file) from a PowerShell command line: Launch the PowerShell as an Administrator and wait for the PS> prompt to appear. Navigate to the directory having your PowerShell script file. Type .\ followed by the ScriptFileName.ps1 and hit Enter to execute the script. [crayon-679095fd4f054975655069/] [crayon-679095fd4f058797970308/] You must […]
- 14 February
Set Environment Variable in PowerShell
Windows Environmental Variables and Their Scope There are three different scopes for environment variables in Windows. Set the Session Environment Variable Set an Environment Variable for a User Using PowerShell Set the Machine Environment Variable Before moving towards solutions, we must know the environment variables and why we use them. System administrators can access a […]
- 14 February
Check if String Contains Number in PowerShell
Using Regular Expression We use regular expressions whenever we are required to look for specific patterns in the text. The regular expressions, also known as regex, comprise operators, literal characters, and other constructs. PowerShell has various cmdlets and operators that allow us to use regex with them; some of them are given below: Using -match […]
- 14 February
PowerShell – Split String into Variables
Using Split() Method Use the Split() method to split the given string into two variables. [crayon-679095fd50041807073081/] [crayon-679095fd50044379076493/] The Split() method is used to split the specified string into two/multiple variables and an array of substrings. In the above example code, the Split() method took two arguments, whitespace as a separator (you can use -, ., […]
- 14 February
Compare Arrays in PowerShell
In this post, we will see how to compare Arrays in PowerShell. PowerShell supports arrays with one or more dimensions and zero to many elements in each dimension. Elements inside a dimension are numbered from 0 in ascending integer order. In addition, the array subscript operator [] allows access to any particular element. PowerShell may […]
- 14 February
Create Temp Directory in PowerShell
Using [System.IO.Path]::GetTempPath() Method with New-Item cmdlet Use the [System.IO.Path]::GetTempPath() with New-Item cmdlet to create a temporary directory in PowerShell. [crayon-679095fd5041b794335492/] [crayon-679095fd5041e722317930/] First, we used the GetTempPath() method of the System.IO.Path class to get the path of a current user’s temporary folder. This method returned a string type value, which we stored in the $temporaryPath variable. […]
- 14 February
Remove Character from String in PowerShell
Remove Character from String in PowerShell Using Replace() Method Use the Replace() method to remove character from a string in PowerShell. Replace() method replaces old character with new Character in the String. [crayon-679095fd50534952588085/] [crayon-679095fd50538636335578/] For the above code, we used the Replace() method to replace Character a with empty space which eventually remove character from […]