PowerShell Cool Tools


Dropdown helper in ISE


Set Export Delimiter (Object Output)                  
$Services = Get-Service        
  Foreach($Service in $Services){
      $obj += [PSCustomObject]@{GroupName = "SCOTT"         
      UserName = "HEAD"
      Job="Chevron Oil"        
      $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

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


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.





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