powershell-profile
powershell-profile copied to clipboard
$timeFilePath for onedrive users
# Define the path to the file that stores the last execution time
$timeFilePath = "$env:USERPROFILE\Documents\PowerShell\LastExecutionTime.txt"
With OneDrive, the Documents folder is USERPROFILE\OneDrive\Documents...
Can't get this profile not to give errors:
Out-File: C:\Users\Oleksandr\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:88 Line | 88 | $currentTime | Out-File -FilePath $timeFilePath | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Could not find a part of the path 'C:\Users\Oleksandr\Documents\PowerShell\LastExecutionTime.txt'. Checking for PowerShell updates... Your PowerShell is up to date. Out-File: C:\Users\Oleksandr\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:129 Line | 129 | $currentTime | Out-File -FilePath $timeFilePath | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Could not find a part of the path 'C:\Users\Oleksandr\Documents\PowerShell\LastExecutionTime.txt'.
If I edit the profile, a) I still get errors from system profile b) I get new errors with personal profile notwithstanding that I changed the path to the correct one