Hello all,
I need to map a cloud drive to the file server. It works when I manually map it but it needs to be available after the server restarts without requiring user sign in. I created a PowerShell script and works when I run it with a regular user and maps the drive.
The issue start when I put the script under startup scripts on local GPO, computer policy > Windows Settings > Scripts > startup (since no user logins to file server). It doesn't map the drive. SYSTEM account has full access to the script location.
My Script is below, I tried many different parameters like this to run the script -Noninteractive -ExecutionPolicy UnRestricted –NoProfile -file
$cred = Import-CliXml -Path "C:\scripts\my-Cloud-Drive-Map.xml"
New-PSDrive -Name "L" -Root "\XXX.file.core.windows.net\yyyy" -Persist -PSProvider "FileSystem" -Credential $cred
Net Use
I also created a batch file to run this script;
PowerShell -Command "Set-ExecutionPolicy Unrestricted -Scope LocalMachine" >> "C:\scripts\StartupLog.txt" 2>&1
Powershell -Noninteractive -ExecutionPolicy Unrestricted -file C:\scripts\my-Cloud-Drive-Map.ps1 >> "C:\scripts\StartupLog.txt" 2>&1
I'm currently testing with Windows 10 Pro but my fileserver is Server 2012 Standard R2
Please advise.
Thank you.
Isac