Windows Updates Script

This is a little script which updates via PowerShell the operating system   #Define update criteria. $Criteria = "IsInstalled=0 and Type='Software'" #Search for relevant updates. $Searcher = New-Object -ComObject Microsoft.Update.Searcher $SearchResult = $Searcher.Search($Criteria).Updates #Download updates. $Session = New-Object -ComObject Microsoft.Update.Session $Downloader = $Session.CreateUpdateDownloader() $Downloader.Updates = $SearchResult $Downloader.Download() #Install updates. $Installer = New-Object -ComObject Microsoft.Update.Installer $Installer.Updates = … Continue reading Windows Updates Script

The Powershell pocket Active directory CMDLets

Computer object commands List all computer accounts in a domain Get-ADComputer –Filter {Name –Like "*"} View all computers that are logged in for 90 days to the Active Directory Search-ADaccount -AccountInactive -Timespan 90 -ComputersOnly OR $lastLogon = (get-date).adddays(-90).ToFileTime() Get-ADComputer -filter {lastLogonTimestamp -gt $lastLogon} Find and delete all disabled Computer accounts in Active Directory Search-ADAccount -AccountDisabled … Continue reading The Powershell pocket Active directory CMDLets