Tuesday, March 9, 2021

Create a URI File to call

 Amazon Workspace Client can use Universal Resource Identifiers (URIs) to launch with predefined parameters such as the username and region code.

This code creates a URI file and makes a call to it.  In practice addtional code would be used to determine the SAMAccountName and RegionCode

$SAMAccountName=mysamaccountname
$RegionCode=myRegionCode

$targetpath = 'workspaces://'+$SAMAccountName+'@'+$RegionCode+'?MFACode=push'

$line1 = '[InternetShortcut]' | Out-File $URIFile
$line2 = 'URL='+$targetpath | Out-File $URIFile -Append
$line3 = 'IconIndex = 0' | Out-File $URIFile -Append
$line4 = 'IconFile=C:\Program Files (x86)\Amazon Web Services, Inc\Amazon\WorkSpaces\workspaces.exe' | Out-File $URIFile -Append

Invoke-Item $URIFile