Getting fields from multiple Powershell Commands

—Single User—
$Mailbox = Get-MailBox "Joe Bloggs"
Get-mailboxstatistics "Joe Bloggs" | ft DisplayName,TotalItemSize,StorageLimitStatus,@{name = 'IssueWarningQuota';expression = {$Mailbox.IssueWarningQuota}},@{name = 'ProhibitSendQuota';expression = {$Mailbox.ProhibitSendQuota}},@{name = 'ProhibitSendRecieveQuote';expression = {$Mailbox.ProhibitSendRecieveQuota}}

—All Users—
$Mailbox = (Get-MailBox *)
foreach ($i in $Mailbox) {Get-mailboxstatistics $i.Name | ft DisplayName,TotalItemSize,StorageLimitStatus,@{name = 'IssueWarningQuota';expression = {$i.IssueWarningQuota}},@{name = 'ProhibitSendQuota';expression = {$i.ProhibitSendQuota}},@{name = 'ProhibitSendRecieveQuote';expression = {$i.ProhibitSendRecieveQuota}} }

—All Users Filtered—
$Mailbox = (Get-MailBox *)
foreach ($i in $Mailbox) {Get-mailboxstatistics $i.SAMAccountName | where {$_.StorageLimitStatus -ne "BelowLimit"} |ft DisplayName,TotalItemSize,StorageLimitStatus,@{name = 'IssueWarningQuota';expression = {$i.IssueWarningQuota}},@{name = 'ProhibitSendQuota';expression = {$i.ProhibitSendQuota}},@{name = 'ProhibitSendRecieveQuota';expression = {$i.ProhibitSendRecieveQuota}} }

—Tidy up formatting—
$Mailbox = (Get-MailBox *)
foreach ($i in $Mailbox) {
$info [email protected](Get-mailboxstatistics $i.SAMAccountName | where {$_.StorageLimitStatus -ne "BelowLimit"} |select-object DisplayName,TotalItemSize,StorageLimitStatus,@{name = 'IssueWarningQuota';expression = {$i.IssueWarningQuota}},@{name = 'ProhibitSendQuota';expression = {$i.ProhibitSendQuota}},@{name = 'ProhibitSendRecieveQuota';expression = {$i.ProhibitSendRecieveQuota}} )
$info | ft -autosize

Scheduled Reboot

Specific time
at 04:00 shutdown -r -t 60 -f -d p:4:1 -c “Description here”

Day of the Month (eg 23rd)
at 21:40 /next:23 shutdown -r -t 60 -f -d p:4:1 -c “Description here”

Day of the week (M,T,W,Th,F,S,Su)
at 21:40 /next:W shutdown -r -t 60 -f -d p:4:1 -c “Description here”

The reason codes can be found in full by typing shutdown and pressing enter!
In the examples above it is Planned Application Maintenance

-r (Reboot)
-t 60 (in 60 Seconds)
-f (force programs to close)
-d p:4:1 (Planned application Maintenance)
-c “Description here” (write a note of “description here” into the logs)

The AT command has been depreciated but you can create a scheduled task for a reboot from the command line still…

schtasks /create /tn "Reboot" /tr "shutdown.exe -r -f -t 00" /sc ONCE /st 04:00:00 /sd 23/12/2020 /ru DOMAIN\USER /rp PASSWORD


Write a batch file containing the following:

cd /d %windir%\system32
Net stop vss
Net stop swprv
regsvr32 ole32.dll
regsvr32 oleaut32.dll
regsvr32 vss_ps.dll
vssvc /register
regsvr32 /i swprv.dll
regsvr32 /i eventcls.dll
regsvr32 es.dll
regsvr32 stdprov.dll
regsvr32 vssui.dll
regsvr32 msxml.dll
regsvr32 msxml3.dll
regsvr32 msxml4.dll
Net start vss
Net start swprv

Kill a stuck Service

sc queryex [servicename]
taskkill /f /pid [PID]

Replace [servicename] with the services registry name. For example: Print Spooler is spooler.
Replace[PID] with the PID returned from the previous command.

Redircmp / Redirusr

Change the default location for new computers and users so that fresh objects can have GPOs applied (you cannot apply GPOs to the default Containers)

redirusr ou=myusers,DC=contoso,dc=com
redircmp ou=mycomputers,DC=contoso,dc=com


At an Administrative Command Prompt enter “Telnet 389”, where 389 is the port you want to connect to on the host. If you are not sending SMTP you will just get an empty black screen if it works.


Eg. MOVES a folder and sub-directories without waiting and without retrying, strips off the security.
robocopy \\from\this\dir \\to\this\dir /e /zb /copy:DAT /r:0 /w:0 /mov

robocopy "E:\source\subfolder" "Q:\target\subfolder" /e /zb /copy:DAT /r:0 /w:0 /move

Note: if you are going to save this as a batch file, don’t call the batch file Robocopy.bat!
…and watch your speech marks. Word destroys them!