PowerShell Script Library #1
New Condensed Format: Click View Button, then Copy Button
A) Query Servers | Export to HTML | Send E-Mail with PowerShell
PowerShell Script that queries servers using WinRM and gathers useful information and then formats it and exports it to a HTML document. Includes, Name, CPU, Hard Disks, RAM (Memory), Last Reboot, Hard Disk Free Space.
Cmdlets:
New-Object PSObject, Get-WMIObject, Invoke-Command
B) Rename File Extensions with PowerShell
At one point I changed my website from HTML to PHP and needed to change file extensions on all my HTML files in my website. This customizable, interactive PowerShell Script will update all files that match input.
Cmdlets:
Foreach, Rename-Item, Tee-Object, Get-Childitem
C) Create Registry Key on Multiple Systems with PowerShell
PowerShell Script to set registry key with lots o trapping for erros to make sure if the key path does not exist then it creates the key path. Next step is it creates the key and sets the value provided.
Cmdlets:
Foreach, Compare-Object, New-Item, Invoke-Command
D) Check for Registry Key on Multiple Systems with PowerShell
Use MS PowerShell to get a list of servers from source text file. tests the path to the key and pulls key value. Returns the Key Value and the ComputerName, also has error tapping built in and error messages.
Cmdlets:
Get-ItemProperty , Test-Path, New-Object PSObject
E) Combine Multiple CSV Files with PowerShell
A network engineer was tasked with reviewing extensive log files from switches and firewalls, and all had the same format but were all in separate files. They only cared about very specific data in these files (30+) and had to open and review each one on a quarterly basis. I decided to write a PowerShell Script to filter all the data and combine required reading to a single report (CSV).
Cmdlets:
Read-Host, Get-ChildItem, -match, Out-File, If, Foreach
F) Search Remote System for Files (OST) Recursive Search
I was assigned a task to audit systems that had OST files that were quite large, and I ended up finding them in more than one place but under a specific parent folder. I was able to create a PowerShell script that searches all items and only by file extension and create a report.
Cmdlets:
Foreach, Compare-Object, New-Item, Invoke-Command