2020 | Scott W. Head  |  Sr. Systems Admin | Certified Microsoft Windows Server Administrator

PowerShell Cool Tools

CTRL+J

Dropdown helper in ISE
 

 



Set Export Delimiter (Object Output)                  
                                        
$Obj=@() 
$Services = Get-Service        
  $X=0
  
  Foreach($Service in $Services){
  
      $obj += [PSCustomObject]@{GroupName = "SCOTT"         
      UserName = "HEAD"
      Location="Redondo"        
      Job="Chevron Oil"        
      Counter=$x    
      } 
      $X = $X+1
  
  }    
        
$obj | Export-Csv -Path C:\temp\export.csv -Delimiter "," -Encoding UTF8 -NoTypeInformation    
        

 



Measure - Quick count of items collected
 

  

        Get-Service | Measure | Select Count | Format-list      
        

 

 

 



Tee-Object - View output and export to text
 

        Get-Service | Select Name, Status | Tee-Object C:\temp\Service.txt -Append

 

 

 



Startswith - Quick check of string and newline `n

   $Myteststring="MeasureMe"
        
        If ($Myteststring.StartsWith("M")){write-host "Starts with an M"}
        
        write-host `n
        
        
        $Myteststring="MeasureMe"
        
        If ($Myteststring.Endswith("e")){write-host "String ends with an e"}
        
        write-host `n
Misc

 




Start-Sleep - Short sleep in the script
 

   Start-Sleep -Seconds 10
        
        Write-host "You just wasted 10 second of your life :P"

 

 

 

 

 

 


Pause the script to require a user to press enter.

 

 

Pause 

‚Äč