PowerShell script to get username and password for FTP from Microsoft Azure publish settings 1

Annoyed about opening all my .PublishSettings files to get the username and password for all my Azure sites when I need to FTP to them (This is a need I have far more often than I am comfortable admitting) I gave up and sacrificed then ten minutes it took me to write a PowerShell script that goes through my PublishSettings catalog and prints them out.

$password = Select-String 'userPWD="[A-z0-9-_]*"' '*.PublishSettings' | Select -Expand Matches
$username = Select-String 'userName="[A-z-_0-9]*\[A-z-_0-9$]*"' '*.PublishSettings' | Select -Expand Matches

$UserLen = $username.Length
$PassLen = $password.Length

if($UserLen -eq $PassLen)
for($i = 0;$i -le $UserLen;$i++)
echo ""
echo $username[$i].Value $password[$i].Value

echo "Error: Could not find passwords for all users."

Feel free to use or change this to suit your needs! As always feel free to comment with questions, criticism or praise

Best regards

//Karl-Henrik “KH” Nilsson

  • khnilsson

    Just testing out Disqus