To get folder from 1 level up:
@echo off
SET CurrentDirectory=%~dp0
echo %CurrentDirectory%
for %%B in (%CurrentDirectory%.) do set ParentFolder=%%~dpB
echo %ParentFolder%
To get folder from 1 level up:
@echo off
SET CurrentDirectory=%~dp0
echo %CurrentDirectory%
for %%B in (%CurrentDirectory%.) do set ParentFolder=%%~dpB
echo %ParentFolder%
Create a password file with securestring:
Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File -FilePath C:\encrypted.securestring
Use the password file to create a PSCredential
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "username",(Get-Content -Path C:\encrypted.securestring | ConvertTo-SecureString)
Reference here.
I realized that this encrypted password only work on the machine which encrypting it.
To have this works on a different computer(s), you would need the key and the encrypted file.