Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ jobs:
$cert = Import-PfxCertificate -FilePath ./cert.pfx -CertStoreLocation Cert:\LocalMachine\My -Password $Password
Set-AuthenticodeSignature InstanceExport.ps1 $cert
shell: pwsh
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
artifacts: ./InstanceExport/PowerShell/InstanceExport.ps1
generateReleaseNotes: true
- name: Publish artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: ./InstanceExport/PowerShell/InstanceExport.ps1
path: ./InstanceExport/PowerShell/InstanceExport.ps1
22 changes: 21 additions & 1 deletion InstanceExport/PowerShell/InstanceExport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,28 @@ Function CreateDirectoryIfDoesNotExist {
}
}

Function GetPassword() {
# assume powershell 7 first
try {
return ConvertFrom-SecureString -SecureString $password -AsPlainText
}
catch {
Log -msg $_.Exception.Message -logLevel "displayInfo" -currentDate $currentDate
}
# fallback to powershell 5
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password)
$UnsecurePassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
if ($UnsecurePassword.Length -gt 1) {
return $UnsecurePassword
}
# we're probably on some non-windows environment... fall back to unsecured
$msg = "Warning: Unable to handle password securely. Falling back to plain text password"
Log -msg $msg -logLevel "displayInfo" -currentDate $currentDate
return Read-Host "$msg. To continue, please enter the password again"
}

Function Login() {
$UnsecurePassword = ConvertFrom-SecureString -SecureString $password -AsPlainText
$UnsecurePassword = GetPassword

$Body = @{
UserName = $userName
Expand Down