The WinRM client received an HTTP server error status (502)

If you get the following error when you try to connect to your WinRM client, try the command below:

Connecting to remote server failed with the following error message: 
The WinRM client received an HTTP server error status 502,  
from the remote ws-managment servic   For more information, 
see the about_Remote_Troubleshooting Help topic. 
It was running the command 'Discover-ExchangeServer -UseWIA $true 
-SuppressError $true'.
Try the command below:
netsh winhttp reset proxy

Deleting and re-adding computers in WSUS

Have you deleted PC from WSUS with remove from WSUS option and you can’t add it back to WSUS? Well try the steps below to fix this problem:

net stop wuauserv
In Registry under HKLM>software>microsoft>windows>currentversion>win dowsupdate delete AccountDomainSid, PingID, SusClientID
net start wuauserv
wuauclt.exe /resetauthorization /detectnow

Get number of mailboxes in each database?

Many times we need to find number of mailboxes in each database and the size of the database (EDB file) of all servers in an Exchange 2010 environment. With PowerShell, it is fairly simple to grab in a single line.

Get-MailboxDatabase | Select Server, StorageGroupName, Name, 
@{Name="Number Of Mailboxes";expression={(Get-Mailbox -Database 
$_.Identity | Measure-Object).Count}} | Format-Table -AutoSize

Export to CSV:

Get-MailboxDatabase | Select Server, StorageGroupName, Name, 
@{Name="Number Of Mailboxes";expression={(Get-Mailbox -Database 
$_.Identity | Measure-Object).Count}} | Export-Csv C:\ServerStat-1.csv

PowerShell – Delete old IIS logs

Just a quick script that may come in useful to you. The below PowerShell script will delete IIS Log files older than 7 days that are in the “C:\inetpub\logs\LogFiles\w3svc1” directory. You can alter the script to how many days old the log files can be and also your IIS log location.

get-childitem -Path C:inetpublogsLogFilesw3svc1 -recurse | where-object {$_.lastwritetime -lt (get-date).addDays(-7)} | Foreach-Object { del $_.FullName }

-Pouyan

PowerShell – Search the Public Folder

If you want search in the public folder database for an folder you can use the scripts below.

If you know the exact name of the folder:

Get-PublicFolder -Identity "" -Recurse | where {$_.Name -eq "FOLDERNAME"}

If you don’t know the exact name:

Get-PublicFolder -Identity "" -Recurse | where {$_.Name -like "FOLDER*"}

-Pouyan