Closed cocallaw closed 1 month ago
@cocallaw - Kindly validate the script version available in branch - issue/3
@AjKundnani I tested using the issue/3 branch and received the following output when the script failed, sensitive information removed
PS /Users/coreycallaway/Documents/Source/Github/Gen1-TrustedLaunch> ./Upgrade-Gen1ToTL.ps1 -subscriptionId $subscriptionId -tenantDomain $tenantDomain -csvLocation ./vmList.csv
PowerShell version is greater than 7.2
Test-Path: /Users/USER/Documents/Source/Github/Gen1-TrustedLaunch/Upgrade-Gen1ToTL.ps1:110
Line |
110 | if ((Test-Path $env:UserProfile)) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
| Value cannot be null. (Parameter 'The provided Path argument was null or an empty collection.')
User profile directory not found. Defaulting to script execution location.
Setting up working dir /Users/USER/Documents/Source/Github/Gen1-TrustedLaunch\Gen1-TrustedLaunch-Upgrade
Module Az.Accounts with minimum version 2.8.0 is available.
Module Az.Compute with minimum version 6.0.0 is available.
WARNING: Module Az.Storage is available, but its version is lower than the minimum version 5.8.0. Upgrading module on local machine.
Connecting to Subscription <AZURE SUB GUID> under <TENANT NAME>.onmicrosoft.com
WARNING: 11:09:25 AM - You may need to login again after updating "EnableLoginByWam".
Key Value Applies To Scope Help Message
--- ----- ---------- ----- ------------
EnableLoginByWam False Az CurrentUser [Preview] When enabled, Web Account Manager (WAM) will be the default interactive login experience. It will fall back to using the browser if the platform does n…
Environments : {[AzureChinaCloud, AzureChinaCloud], [AzureUSGovernment, AzureUSGovernment], [AzureCloud, AzureCloud]}
Context : Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext
Feature Gen1ToTLMigrationPreview is already registered.
Script Version: 2.1.1
Error Exception Occurred
Write-LogEntry()
Could not find a part of the path '/Gen1-TrustedLaunch-Upgrade/gen1avd-1-Gen1-TL-Upgrade-24.09.16-11.10.13.log'.
-1
Enable Secure Boot = True
Output Storage Account Name =
VM name = gen1avd-1
Use Signed Script =
Tenant Domain = <TENANT NAME>onmicrosoft.com
Subscription ID = <AZURE SUB GUID>
Resource group name = rg-avd-gen1-neu
Use Cloud Shell =
Error Exception Occurred
Write-LogEntry()
Could not find a part of the path '/Gen1-TrustedLaunch-Upgrade/gen1avd-1-Gen1-TL-Upgrade-24.09.16-11.10.13.log'.
-1
Processing VM gen1avd-1 under resource group rg-avd-gen1-neu with Secure boot TRUE
Error Exception Occurred
Write-LogEntry()
Could not find a part of the path '/Gen1-TrustedLaunch-Upgrade/gen1avd-1-Gen1-TL-Upgrade-24.09.16-11.10.13.log'.
-1
@cocallaw - Added fix. Kindly check.
Closing as fix is added for Windows machines without user profile. For Macintosh machines, request to leverage CloudShell to execute the orchestration.
When running the script if the user's environment does not have the environment variable $env:UserProfile set, the script will fail with an error message that does not helo the user understand the issue that they are experiencing.
Adding if statement to check if the value of $env:UserProfile is not null or empty provides option to either log error and exit or set value to something else
if ([string]::IsNullOrEmpty($env:UserProfile)) { }
Example:
Output with if statement