Scripts/Set-StoredCredentialPath.ps1
Function Set-StoredCredentialPath { [CmdletBinding()] Param( [string]$Path ) if (!($PSBoundParameters.ContainsKey('path'))) { [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null $foldername = New-Object System.Windows.Forms.FolderBrowserDialog $foldername.Description = "Select a folder" $foldername.rootfolder = "MyComputer" $foldername.SelectedPath = $initialDirectory if ($foldername.ShowDialog() -eq "OK") { $path += $foldername.SelectedPath } } else { If (!(Test-Path $Path)) { New-Item -Path $Path -ItemType Directory } } $env:StoredCredentialPath = $Path [System.Environment]::SetEnvironmentVariable('StoredCredentialPath', $Path, [System.EnvironmentVariableTarget]::User) } |