These drives are very useful, but they are available only within Windows PowerShell. The Windows PowerShell providers create some drives for you, such as the file system drives (including C: and D:), the registry drives (HKCU: and HKLM:), and the certificate drive (Cert:), and you can create your own Windows PowerShell drives. New-PSDrive -Name "K" -PSProvider "FileSystem" -Root \\UNCPathGoesHere -Credential $SecureCredential -Persist A note on Powershell drives #Ī Windows PowerShell drive is a data store location that you can access like a file system drive in Windows PowerShell. $SecureCredential = New-Object ($User,$EncryptedPass) $EncryptedPass = Get-Content C:\Scripts\Creds.txt | ConvertTo-SecureString $Credential.Password | ConvertFrom-SecureString | Set-Content C:\Scripts\Creds.txt You can rework the code in option 1 to look like the following: #Prompt the user for credentials and store into a file in encrypted format New-SMBMapping -LocalPath "K:" -RemotePath $NetworkPath -UserName $User -Password $PWord -Persistentīasic limitation of both the above options is that the password will need to reside in plain text in some part of the code. You can make use of the New-SmbMapping command. Invoke-Command -ComputerName $ComputerName -ScriptBlock $ScriptBlockĪAD Joined Machine Using P2S VPN to Access Storage File Shares -3 Create P2S VPN
0 Comments
Leave a Reply. |