CrossTenantIdentityMappingModlueSetup.ps1
|
Param( [Parameter(Mandatory = $false, HelpMessage = "Enter the branch to pick the build from.")] [ValidateSet("Nibiru")] [string] $Branch, [Parameter(Mandatory = $false, HelpMessage = "Enter the target dir where Net Framework build for the module is present")] [string] $BinaryLocationNetFramework, [Parameter(Mandatory = $true, HelpMessage = "Enter the module version")] [string] $ReleaseVersion, [Parameter(Mandatory = $false, HelpMessage = "Preview string to use.")] [string] $PreviewString = "", [Parameter(Mandatory = $false, HelpMessage = "Build Flavor : debug/retail")] [ValidateSet('debug', 'retail')] [string] $BuildFlavor = 'retail', [Parameter(Mandatory = $false, HelpMessage = "Enter the build version to validate.e.g. From Substrate '20.00.3278.000' or From Nibiru '17.00.4356.000'")] [string] $BuildVersion, [Parameter(Mandatory = $false, HelpMessage = "Output path given in the original Script")] [string] $OutputPath = ".", [Parameter(Mandatory = $false, HelpMessage = "Provide switch to create a preview release ")] [switch] $PreviewRelease, [Parameter(Mandatory = $false, HelpMessage = "OutputParam which would store DllPath")] [ref]$DllPathOutputParam ) if ($Branch -ne '' -and $Branch -ne $null) { if ($Branch -eq "Nibiru") { $BinaryLocationNetFramework = "\\redmond\exchange\Build\Nibiru\$BuildVersion\target\dev\enterprisecloud\imcmdlets\$BuildFlavor\amd64"; } } if (-not (Test-Path -Path $BinaryLocationNetFramework)) { Write-Error "$BinaryLocationNetFramework is not accessible." return } Write-Host "Picking the module from the location : $BinaryLocationNetFramework"; if ((Test-Path -Path $OutputPath) -eq $true) { #Clean up the directory to eliminate stray files creeping in. Remove-Item $OutputPath -Recurse } Write-Host "Creating folder : $OutputPath" New-Item -Path $OutputPath -ItemType Directory if ($DllPathOutputParam -ne $null) { $DllPathOutputParam.value = $OutputPath } # Create a directory to copy the symbols from redmond for output/publish Write-Host "Copying all the required files from $BinaryLocationNetFramework to $OutputPath directory." # Copys all dlls needed for IM powershell $excludes = @('System.Management.Automation.dll') Copy-Item -Path $BinaryLocationNetFramework\*.dll -Destination $OutputPath\. -Exclude $excludes -Recurse # Cheack to make sure right number and most important dll are in OutputPath $copiedDlls = Get-ChildItem $OutputPath if($copiedDlls.Count -lt 10 -or -not ($copiedDlls -Match "Microsoft.CrossTenant.IdentityMapping.IMCmdlets.dll")) { Write-Error "$OutputPath does not contain correct dll files" return } Copy-Item -Path $BinaryLocationNetFramework\LICENSE.txt -Destination $OutputPath -ErrorAction Stop Copy-Item -Path $BinaryLocationNetFramework\NOTICE.txt -Destination $OutputPath -ErrorAction Stop Write-Host $PSScriptRoot $createOfficialReleasePSDCommand = "$BinaryLocationNetFramework/CreateIMOfficialReleasePSDFile.ps1" Write-Host $createOfficialReleasePSDCommand $releaseNotesFilePath = "$BinaryLocationNetFramework/ModuleOfficialReleaseNotes.txt" Write-Host $releaseNotesFilePath $cmdletPublishFilePath = "$BinaryLocationNetFramework/CmdletPublishList.txt" Write-Host $cmdletPublishFilePath $createOfficialReleasePSDCommand += ' -ReleaseNotesFile $releaseNotesFilePath -ReleaseVersion $ReleaseVersion -PreviewString $PreviewString -DllPath $OutputPath -CmdletPublishFile $cmdletPublishFilePath -OutputPath $OutputPath' if ($PreviewRelease -eq $true) { $createOfficialReleasePSDCommand += ' -PreviewRelease' } Write-Host $createOfficialReleasePSDCommand # This isn't vulnerable to PowerShell injection or isn't interesting to exploit. Justification: This script is not run on any server and is only run manually by a dev locally with Nibiru retail builds. $scriptBlock = [Scriptblock]::Create($createOfficialReleasePSDCommand) Invoke-Command -Command $scriptBlock |