WINDOWS POWERSHELL COMMANDS
Open your power shell from command prompt as a administrator.
Point to remember : Declare any variable with $y in PowerShell
C:\WINDOWS\system32>$array ="India","Japan","Aus","US","UK"
C:\WINDOWS\system32> $array
It will list an array
PS C:\WINDOWS\system32> $array[2]
It gives value on index 2 , which is AUS in our case.
$array=("India","Asia"),("Japan","Asia"),("AUstralia","Australia"),("UK","EUROPE"),("US","North America”)
PS C:\WINDOWS\system32> $array
PS C:\WINDOWS\system32> $array[0][1]
Asia
PS C:\WINDOWS\system32> $array[1][1]
Asia
PS C:\WINDOWS\system32> $array[1][0]
======================================
Some mathematical commands show below:
PS C:\WINDOWS\system32> $y=get-service
PS C:\WINDOWS\system32> $y.count
292
PS C:\WINDOWS\system32> [math]::sqrt("9")
3
PS C:\WINDOWS\system32> $x="192.78788"
PS C:\WINDOWS\system32> [math]::round($x,2)
192.79
4. To update the value of an index in array as shown below:
PS C:\WINDOWS\system32> $array[1][0]="Singapore"
PS C:\WINDOWS\system32> $array[1][0]
5. To change the variable case in upper and lower use the following command
PS C:\WINDOWS\system32> $x="The quick brown fox jumps right over the lazy little dogs"
PS C:\WINDOWS\system32> $x.ToUpper()
THE QUICK BROWN FOX JUMPS RIGHT OVER THE LAZY LITTLE DOGS
PS C:\WINDOWS\system32> $x.TOLOWER()
Output
the quick brown fox jumps right over the lazy little dogs
6. To replace any word
PS C:\WINDOWS\system32> $x.replace("The","That")
That quick brown fox jumps right over the lazy little dogs
7. To Get complete service object in a variable
Declare any variable with $y in PowerShell
PS C:\WINDOWS\system32> $y=get-service
PS C:\WINDOWS\system32> $y.count
Output : 292