Hi All,
I created a powershell script to check every 60 seconds the counts of Move requests on O365... It works exactly how I want it to... but it's in a list based format...
So output would show:
Autosuspended: 1
Completed: 2
Failed:3
And so on... and every 60 seconds it would just post it again. Now this works, but I would rather want my output in a table format. Like this: (Ok so the website screws this up, but it's a table format)
Run Date:
AutoSuspended: Completed:Failed:
================================================
10/06/2014 10:00:00 1 2 3
10/06/2014 10:01:00 2 2 1
and so forth... so every time it runs, it just adds a new row...
Could anyone help me with that sort of formatting?
This is the script:
param($Work) # restart PowerShell with -noexit, the same script, and 1 if (!$Work) { powershell -noexit -file $MyInvocation.MyCommand.Path 1 return } #PARAMETERS: Write-Host echo 'ENTER USERNAME: (Exchange Online tenant administrator):' $username = read-host echo 'ENTER PASSWORD: ' $password = read-host -assecurestring #CONNECT TO O365 $UserCredential = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password Write-Host "CONNECTING..." -Foregroundcolor Yellow $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session #HEADER $Host.UI.RawUI.WindowTitle = "Exchange Online: Get-Move-Queue-Counts" Write-Host "=========================================================================================================" -ForegroundColor Yellow Write-Host "NAME: Exchange Online: Get-Move-Queue-Counts" -Foregroundcolor Yellow Write-Host "REFRESH RATE: 60s" Write-Host "=========================================================================================================" -ForegroundColor Yellow function GetStats { Write-Host $RunDate "> Running " Get-Date -ForegroundColor Cyan [Int] $intAutoSuspended = $intCompleted = $intCompletedWithWarning = $intCompletionInProgress = $intFailed = $InProgress = $intNone = $intQueued = $intSuspended = 0 Get-MoveRequest | Where {$_.status -eq "AutoSuspended"} | ForEach { $intAutoSuspended++ } if ($intNone -eq 5000) { Write-Host "AutoSuspended: > 5000" } ELSE {Write-Host "AutoSuspended: " $intAutoSuspended} Get-MoveRequest | Where {$_.status -eq "Completed"} | ForEach { $intCompleted++ } if ($intFailed -eq 5000) { Write-Host "Completed: > 5000" } ELSE {Write-Host "Completed: " $intCompleted} Get-MoveRequest | Where {$_.status -eq "CompletedWithWarning"} | ForEach { $intCompletedWithWarning++ } if ($intPending -eq 5000) { Write-Host "CompletedWithWarning: > 5000" } ELSE {Write-Host "CompletedWithWarning: " $intCompletedWithWarning} Get-MoveRequest | Where {$_.status -eq "CompletionInProgress"} | ForEach { $intCompletionInProgress++ } if ($intDelivered -eq 5000) { Write-Host "CompletionInProgress: > 5000" } ELSE {Write-Host "CompletionInProgress: " $intCompletionInProgress} Get-MoveRequest | Where {$_.status -eq "Failed"} | ForEach { $intFailed++ } if ($intExpanded -eq 5000) { Write-Host "Failed: > 5000" } ELSE {Write-Host "Failed: " $intFailed} Get-MoveRequest | Where {$_.status -eq "InProgress"} | ForEach { $InProgress++ } if ($intExpanded -eq 5000) { Write-Host "InProgress: > 5000" } ELSE {Write-Host "InProgress: " $InProgress} Get-MoveRequest | Where {$_.status -eq "None"} | ForEach { $intNone++ } if ($intExpanded -eq 5000) { Write-Host "None: > 5000" } ELSE {Write-Host "None: " $intNone} Get-MoveRequest | Where {$_.status -eq "Queued"} | ForEach { $intQueued++ } if ($intExpanded -eq 5000) { Write-Host "Queued: > 5000" } ELSE {Write-Host "Queued: " $intQueued} Get-MoveRequest | Where {$_.status -eq "Suspended"} | ForEach { $intSuspended++ } if ($intExpanded -eq 5000) { Write-Host "Suspended: > 5000" } ELSE {Write-Host "Suspended: " $intSuspended} } while(1) { GetStats start-sleep -seconds 60 }
\\Tjopsta// http://www.tjopsta.net