In on-prem scenarios you might want to use Temporary user profiles and still be able to access data on UNC paths on other servers

There are two scenarios:

  1. You map an UNC share with one single user account for all users (pw visible in script or UI variable):
    if (-not (Test-Path S:)) { $username = "mydomain\sa-share" $password = "MyS3cretP@$$word" net use S: \\host\share /persistent:yes /USER:$username $password }
    With this solution the drive is mapped with the same special user for all user sessions. You either have to specify the password in the script like above or create a variable in PowerTags like
    SAPW=MyS3cretP@$$word

    and then in the script above use

    $password = "$env:SAPW"


  2. You map an UNC share per user:
    if (-not (Test-Path S:)) { $cred = Get-Credential "mydomain\$env:USER_SHORTID" net use S: \\host\share /persistent:yes /USER:$($cred.UserName) $cred.GetNetworkCredential().password }
    This opens a Windows login dialog:
Both scripts go into StartupBeforeSync.ps1 (Session scripting (Windows))


You might wonder why net use is used in a PowerShell script and not New-PSDrive. That is because New-PSDrive is buggy when it comes to persistence and net use just works fine.


After mapping, you can add the mapped drive or path into your Cameyo dialog using the following PowerTag:

!FILEDIALOG_EXTRA=SHARE>0>S:\

see: Cameyo File Dialog