Thursday, September 11, 2014

Cleanup WinSxS

Cleanup WinSxS with PowerShell, remove features on demand in Windows Server 2012.

001
Get-WindowsFeature | where-object{$_.Installed -eq 0 -and $_.InstallState -eq 'Available'}


001
Get-WindowsFeature | where-object{$_.Installed -eq 0 -and $_.InstallState -eq 'Available'| uninstall-windowsfeature -remove

Sunday, August 17, 2014

Bored?

The below script with go through a list of PowerShell links and open them each up one at a time within a single tab. Every 2 seconds a new article will appear -- when you find something good just hit [CTRL]+C to stop the script form continuing.



001
002
003
004
005
006
007
008
009
010
011

$blog="http://www.matthewkerfoot.com/p/powershell-links.html"
$ie = new-object -com internetexplorer.application
$iwr = Invoke-WebRequest -Uri $blog
$links = $iwr.Links | Select-Object -skip 7 -ExpandProperty href
foreach($l in $links){
                        $ie.visible=$true
                        $ie.navigate("$l")
                                while ($ie.Busy -eq $true){ 
                                                            Wait-Event -Timeout 2
                                }
}

Tuesday, August 12, 2014

Easiest way to create a lot of AD accounts.


If $number is an array from 1 to 300 and for every number or $n we run New-ADUser -name $n were going to get 300 users with names like 1, 2 , 3, 4..300.

001
002
003
004
005
006
PS C:\> 1..5 # sample Array
1
2
3
4
5

001
002
003
004
$number = 1..300
foreach ($n in $number){
New-ADUser -name $n -verbose
}