Created
June 14, 2016 15:50
-
-
Save davops/060db005e6fe7f9d5b25d16e527b4b0c to your computer and use it in GitHub Desktop.
Revisions
-
davops created this gist
Jun 14, 2016 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #Deleting Sites and app pools in IIS 7 with PowerShell $appCmd = "C:\windows\system32\inetsrv\appcmd.exe" #lists all the sites & $appcmd list site #deletes a specific site & $appcmd delete site "Name of site" #deletes a specific application pool & $appcmd delete apppool "Name of app pool" #delete any app pools that use a certain username (in the identity column of the GUI) $account = "TheDomain\TheAccount" $AppPools = & $appcmd list apppool /processModel.userName:$account foreach ($pool in $AppPools){ $pool = $pool.split(" ")[1] #get the name only & $appcmd delete apppool $pool } #delete all app pools that use a certain username except for a given app pool name $account = "TheDomain\TheAccount" $AppPools = & $appcmd list apppool /processModel.userName:$account foreach ($pool in $AppPools){ $pool = $pool.split(" ")[1] #get the name only if ($pool -ne "MyAppPool") { & $appcmd delete apppool $pool } }