Tips & Tricks
Everything you ever wanted to know but never dared to search for...

Replace a string in a file

$(get-content c:\tempa\site.css) | foreach-object {$_ -replace "image.png", "new.jpg"} | set-content c:\tempa\site.css

Search multiple strings in multiple files within subfolders

Get-ChildItem -Path "C:\Logs\" -recurse -filter "SystemOut_201408*.log" | Select-String -pattern "caused by:", "exception:"

Get System and hardware info from remote servers

Get-WmiObject -Query "SELECT * FROM Win32_LogicalDisk"-ComputerName [servername]
Get-WmiObject -Query "SELECT TotalPhysicalMemory FROM Win32_ComputerSystem" -cn [servername]
Get-WmiObject Win32_Processor -cn [servername]

And how to get a list of all available wmi object for querying:
Get-WmiObject -List |Where-Object { $ -match 'memory' }

Gaetano Causio © | Privacy Policy | Disclaimer