Created
September 3, 2018 15:46
-
-
Save SMSAgentSoftware/fa01bfa76d703375cd8abf75aabd8e9a to your computer and use it in GitHub Desktop.
Gets the Office 365 / Click-to-run configuration from local or remote computers
This file contains hidden or 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 characters
| <# | |
| .Synopsis | |
| Retrieves O365/C2R info from a local or remote registry | |
| .DESCRIPTION | |
| Retrieves some basic info on the Office 365 / Click-to-run installation on the local or remote computer/s, such as products installed, version number, activation account, bitness etc. | |
| Requires PS remoting to be enabled for remote computer access. | |
| .PARAMETER ComputerName | |
| [Optional] the name or names of remote computers | |
| .EXAMPLE | |
| Get-OfficeC2RInfo | |
| Returns O365 info for local computer | |
| .EXAMPLE | |
| Get-OfficeC2RInfo -ComputerName PC001 | |
| Returns O365 info for a remote computer | |
| .EXAMPLE | |
| 'PC001','PC002','PC003' | Get-OfficeC2RInfo | |
| Returns O365 info for a group of remote computers | |
| .EXAMPLE | |
| 'PC001','PC002','PC003' | Get-OfficeC2RInfo | Out-Gridview | |
| Returns O365 info for a group of remote computers and display in Gridview | |
| #> | |
| [CmdletBinding()] | |
| Param | |
| ( | |
| [Parameter(Mandatory=$false, | |
| ValueFromPipelineByPropertyName=$true, | |
| ValueFromPipeline=$true, | |
| Position=0)] | |
| $ComputerName = $env:COMPUTERNAME | |
| ) | |
| Begin | |
| { | |
| # Set registry location and define the keys | |
| $RegBranch = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration" | |
| $Keys = @( | |
| 'ClientVersionToReport' | |
| 'ClientCulture' | |
| 'O365ProPlusRetail.EmailAddress' | |
| 'O365ProPlusRetail.MediaType' | |
| 'Platform' | |
| 'ProductReleaseIds' | |
| 'UpdatesEnabled' | |
| 'UpdateChannel' | |
| ) | |
| # Define the scriptblock | |
| $ScriptBlock = { | |
| Param($Keys,$RegBranch) | |
| # Load the reg key values into a hash table | |
| $Results = [ordered]@{} | |
| $Results.Add("ComputerName",$env:COMPUTERNAME) | |
| Foreach ($Key in $Keys) | |
| { | |
| $Results.Add($Key,((Get-ItemProperty -Path $RegBranch -Name $key -ErrorAction SilentlyContinue).$Key)) | |
| } | |
| $Results | |
| } | |
| } | |
| Process | |
| { | |
| Foreach ($Computer in $ComputerName) | |
| { | |
| # Invoke the code | |
| If ($Computer -eq $env:COMPUTERNAME) | |
| { | |
| $ResultsHash = Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Keys,$RegBranch | |
| } | |
| Else | |
| { | |
| $ResultsHash = Invoke-Command -ComputerName $Computer -ScriptBlock $ScriptBlock -ArgumentList $Keys,$RegBranch | |
| } | |
| # Reload the data into a datatable | |
| $ResultsTable = [System.Data.DataTable]::new() | |
| $ResultsArray = @() | |
| Foreach ($Key in $ResultsHash.Keys | Sort) | |
| { | |
| [void]$ResultsTable.Columns.Add("$Key") | |
| $ResultsArray += $ResultsHash["$Key"] | |
| } | |
| [void]$ResultsTable.Rows.Add($ResultsArray) | |
| # Set the computername column as the first column | |
| $ResultsTable.Columns["ComputerName"].SetOrdinal(0) | |
| # Display the results | |
| $ResultsTable | |
| } | |
| } | |
| End | |
| { | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment