Created
August 19, 2019 10:39
-
-
Save alexverboon/22c7e050e1f377022176322efb51cd73 to your computer and use it in GitHub Desktop.
Start-OfficeReadinessCollection
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
function Start-OfficeReadinessCollection | |
{ | |
<# | |
.Synopsis | |
Start-OfficeReadinessCollection | |
.DESCRIPTION | |
Start-OfficeReadinessCollection is a wrapper script for the Readiness Toolkit for Office add-ins and VBA | |
.PARAMETER OutPutPath | |
Specifies the path where the Office Readiness Assessment results are stored. | |
.PARAMETER MRU | |
Indicates that the Office Readiness tool scans the users most recent used files | |
.PARAMETER MyDocuments | |
Indicates that the Office Readiness tool scans the content of the users MyDocuments folder including subfolders. | |
.PARAMETER DocLocation | |
Indicates that the Office Readiness tool scans the content of the specified folder including subfolders. | |
.PARAMETER addins | |
Indicates whether the Office add-ins are included in the assessment. This parameter is optional | |
.EXAMPLE | |
Start-OfficeReadinessCollection -OutPutPath C:\data\scanresults -MRU -addins | |
This command scans the users most recently used files and add-ins | |
.EXAMPLE | |
Start-OfficeReadinessCollection -OutPutPath C:\data\scanresults -MyDocuments -addins | |
This command scans the content of the users Mydocuments folder and add-ins | |
.EXAMPLE | |
Start-OfficeReadinessCollection -OutPutPath C:\data\scanresults -DocLocation c:\data -addins | |
This command scans the content of the specified folder and add-ins | |
.NOTES | |
v1.0, 19.08.2019, alex verboon | |
https://docs.microsoft.com/en-us/deployoffice/use-the-readiness-toolkit-to-assess-application-compatibility-for-office-365-pro | |
https://www.microsoft.com/en-us/download/details.aspx?id=55983 | |
#> | |
Param | |
( | |
# Specifies the path where the Office Readiness Assessment results are stored | |
[Parameter(Mandatory=$true, | |
ValueFromPipelineByPropertyName=$true, | |
Position=0)] | |
[string]$OutPutPath, | |
# Indicates whether the Office add-ins are included in the assessment | |
[Parameter(Mandatory=$false, | |
ValueFromPipelineByPropertyName=$true, | |
Position=0)] | |
[switch]$addins, | |
# Assess documents from users most recent used files | |
[Parameter(Mandatory=$false, | |
ParameterSetName = "MRU", | |
ValueFromPipelineByPropertyName=$true, | |
Position=0)] | |
[switch]$MRU, | |
# Assess documents located in My Documents | |
[Parameter(Mandatory=$false, | |
ParameterSetName = "MyDocuments", | |
ValueFromPipelineByPropertyName=$true, | |
Position=0)] | |
[switch]$MyDocuments, | |
# Assess documents stored in specified Location | |
[Parameter(Mandatory=$false, | |
ParameterSetName = "CustomLoction", | |
ValueFromPipelineByPropertyName=$true, | |
Position=0)] | |
[string]$DocLocation | |
) | |
Begin | |
{ | |
# Get Current script Location | |
$ScriptPath = $PSScriptRoot | |
Write-Output "Current Script Path $ScriptPath" | |
# Check if Office Readiness Report Creator tool is present | |
If (Test-Path "$ScriptPath\ReadinessReportCreator.exe" -PathType Leaf) | |
{ | |
Write-output "Office Readiness Report Creator found" | |
} | |
Else | |
{ | |
Write-output "Office Readiness Report Creator not found" | |
Write-Output "Download the tool from: https://www.microsoft.com/en-us/download/details.aspx?id=55983" | |
break | |
} | |
# Check if Assessment output location exists | |
If (Test-Path $OutPutPath -PathType Container) | |
{ | |
Write-output "Results output path: $OutPutPath found" | |
} | |
Else | |
{ | |
Write-output "Results output path $OutPutPath NOT found" | |
Break | |
} | |
# check if office add-ins are to be included in scan as well | |
if ($PSBoundParameters.ContainsKey(‘addins’)) | |
{ | |
Write-Output "Add-in scan: enabled" | |
$addinscanparam = "-addinscan" | |
} | |
# When specified, check if MyDocuments folder is present | |
if ($PSBoundParameters.ContainsKey(‘MyDocuments’)) | |
{ | |
$MyDocs = [Environment]::GetFolderPath("MyDocuments") | |
If (Test-Path "$MyDocs" -PathType Container) | |
{ | |
Write-Output "MyDocuments folder $MyDocs found" | |
$ScanScope = "MyDocuments" | |
Write-Output "ScanScope: $ScanScope" | |
} | |
Else | |
{ | |
Write-Output "MyDocuments folder $MyDocuments NOT found" | |
Break | |
} | |
} | |
# When specified, check if provided folder path is present | |
if ($PSBoundParameters.ContainsKey(‘DocLocation’)) | |
{ | |
If (Test-Path "$DocLocation" -PathType Container) | |
{ | |
Write-Output "Custom file location: $DocLocation found" | |
$ScanScope = "CustomLocation" | |
Write-Output "ScanScope: $ScanScope" | |
} | |
Else | |
{ | |
Write-Output "Custom file location $DocLocation NOT found" | |
Break | |
} | |
} | |
if ($PSBoundParameters.ContainsKey(‘MRU’)) | |
{ | |
$ScanScope = "MRU" | |
Write-Output "ScanScope: $ScanScope" | |
} | |
} | |
Process | |
{ | |
# Start Office Readiness Collection Toolkit | |
If ($ScanScope -eq "MRU") | |
{ | |
Write-Output "Starting Office Readiness Toolkit - ScanScope $ScanScope" | |
& "$ScriptPath\ReadinessReportCreator.exe" -mru $addinscanparam -output $OutPutPath -silent | |
} | |
If ($ScanScope -eq "CustomLocation") | |
{ | |
Write-Output "Starting Office Readiness Toolkit - ScanScope $ScanScope" | |
& "$ScriptPath\ReadinessReportCreator.exe" -p $DocLocation -r $addinscanparam -output $OutPutPath -silent | |
} | |
If ($ScanScope -eq "MyDocuments") | |
{ | |
Write-Output "Starting Office Readiness Toolkit - ScanScope $ScanScope" | |
& "$ScriptPath\ReadinessReportCreator.exe" -p $MyDocs -r $addinscanparam -output $OutPutPath -silent | |
} | |
} | |
End | |
{ | |
Write-Output "Results saved to: $OutPutPath" | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment