Home » Questions » Computers [ Ask a new question ]

Your favorite/usefull powershell scripts [closed]

Your favorite/usefull powershell scripts [closed]

Along the same lines of the question about autohotkey scripts: superuser.com/questions/7271/, just now it's about Powershell.

Asked by: Guest | Views: 67
Total answers/comments: 2
Guest [Entry]

"Get-RecentUpdates.ps1, this will list the recent (default: last 7 days) updates from Microsoft Update (it is somewhat work in progress, some of the formatting should be moved to a .xmlps1 format definition):

#requires -Version 2.0
# Copyright Richard J Cox 2009. Use freely at your own risk

param([switch]$RawDisplay,
[DateTime]$After = $([datetime]::Today.AddDays(-7)),
[string]$Computer = '')

$extraArgs = @{}
if ($Computer.Length -gt 0) {
$extraArgs.Computer = $Computer
}

$events = get-eventlog -After $after -logname system -InstanceId 19 -source ""Microsoft-Windows-WindowsUpdateClient"" @extraArgs |
select-Object -property EventId, Index, Source, TimeGenerated,
@{n='Message';e={$_.ReplacementStrings | Select-Object -first 1}}

if ($rawDisplay) {
$events
} else {
$events | ft -a -wrap Index, TimeGenerated, Message
}"
Guest [Entry]

"My profile script - sources a shared directory with a bunch of useful scripts:

$SharedScripts = '\\FileServer\Share\PowerShell\Scripts'
Get-ChildItem ""$SharedScripts\*.ps1"" | % {
. $_
Write-Host ('Loaded shared library: ' + [System.IO.Path]::GetFileNameWithoutExtension($_))
}"