PowerShell

Get Started. It's Free
or sign up with your email address
Rocket clouds
PowerShell by Mind Map: PowerShell

1. Get Commands

1.1. Get-Command

1.1.1. 'Get-Command -noun'

1.1.1.1. 'Get-command -noun *Service'

1.1.2. 'Get-Service'

1.1.3. 'Get-Help'

1.1.3.1. 'Get-Help Get "..." -Examples'

1.1.3.2. 'Get-Help Get "..." -Online

1.1.4. 'Get-Process'

1.1.4.1. EX: 'Get-Process -Name MicrosoftEdge

1.1.4.2. Piping EX: get-process -name MicrosoftEdge | Get-Member

1.1.4.3. EX: 'get-process -name MicrosoftEdge | Select-Object *'

1.1.5. 'Get-History'

1.1.6. 'Get-PSDrive'

2. Lesson Four (Write Host)

2.1. 'Write-Host' simply just writes to the screen

2.2. 'Tee-Object' Goes into a path and passes one output to the file and one to the screen

2.3. 'Write-Error" Allows user to write error text to the screen

2.4. 'Write-Warning"

3. PowerShell & Strings

3.1. Commons Functions

3.1.1. "Variable".ToUpper()

3.1.2. "Variable".ToLower()

3.1.3. "Variable".Contains("") will return a boolean

3.1.4. 'Rename-Item'

3.1.5. .Substring()

3.2. Other Examples

3.2.1. "Trimstar" & "IndexOf" & "SubString"

4. FIRST & Tips

4.1. type 'Start-Transcript'

4.2. Pressing up(arrow key), gives you the last command you used

4.3. PowerShell has Alias such as 'cls'

4.3.1. 'get-alias "..." '

4.3.2. 'get-alias'

4.3.2.1. EX: 'get-alias ?'

4.4. '& "file path" ' will open an application

4.5. Can divide by ' "value"/gb'

4.6. "{0:N0}" -f

4.7. Write-Host

5. Variables

5.1. EX: '$zebra' = Get-Process MicrosoftEdge

5.1.1. $zebra.Name

6. Lesson Two

6.1. Get-PSDrive | ?{$_.Free -gt 1} | %{$Count = 0; Write-Host "";} { $_.Name + ": Used: " + "{0:N2}" -f ($_.Used/1gb) + " Free: " + "{0:N2}" -f ($_.free/1gb) + " Total: " + "{0:N2}" -f (($_.Used/1gb)+($_.Free/1gb)); $Count = $Count + $_.Free;}{Write-Host"";Write-Host "Total Free Space " ("{0:N2}" -f ($Count/1gb)) -backgroundcolor magenta}

6.1.1. Get-PSDrive

6.1.2. Get-PSDrive | Where-Object {$_.free -gt 1}

6.1.2.1. '?' means 'Where-Object'

6.1.2.2. '$_.free' represents the current item in the pipe

6.1.3. Get-PSDrive | Where-Object {$_.free -gt 1} | Select-Object root, used, free

6.1.3.1. 'Select-Object' allows for specific items to be selected

6.1.4. ForEach-Object

6.1.4.1. Get-PSDrive | Where-Object {$_.free -gt 1} | ForEach-Object {"Zebra"}

6.1.4.2. Get-PSDrive | Where-Object {$_.free -gt 1} | ForEach-Object {Write-Host "Free space for" $_.root is $_.free -Foreground Color Red}

6.1.4.3. Get-PSDrive | Where-Object {$_.free -gt 1} | ForEach-Object{$c=0; Write-Host "This step only runs once."}{$c = $c+1;Wri te-host "This section runs once for each object in the pipe." $c}

6.1.4.4. '%' means 'foreach-object'

6.1.5. "{0:N0}" -f 1000000

7. Lesson One

8. Lesson Three (The File System)

8.1. 'cd' is the command for 'set-location'

8.2. 'dir' is the command for 'get-childitem'

8.3. 'md' is the command for 'mkdir' & /or 'new-item -ItemType Directory "" '

8.4. 'remove-item'

8.5. 'copy-item'