rubrikinc / rubrik-scripts-for-powershell

Collection of PowerShell Scripts created to interact to Rubrik CDM
MIT License
50 stars 58 forks source link

Credentials file generated by Create-SecurePasswordFile.ps1 cannot be used by Rubrik PowerShell scripts #89

Closed JanPillarRubrik closed 5 years ago

JanPillarRubrik commented 5 years ago

What happened: Generating credentials file using Create-SecurePasswordFile.ps1 generates a PW file that cannot be used by Rubrik Scripts, such as Export-RubrikDatabasesJob.ps1.

What you expected to happen: The expectation is that Create-SecurePasswordFile.ps1 generates a credentials file that can be used by Export-RubrikDatabasesJob.ps1.

But that is not the case, the credentials file for Export-RubrikDatabasesJob.ps1 must be generated using different syntax:

$Credential = Get-Credential 
$Credential | Export-CliXml -Path "<credentials_file>" 

How to reproduce it (as minimally and precisely as possible): 1) Generate a credentials file using Create-SecurePasswordFile.ps1. 2) Use it with Export-RubrikDatabasesJob.ps1 - it does not work.

Anything else we need to know?: N/A

jaapbrasser commented 5 years ago

Hello Jan,

Which operating system and PowerShell version are you using? You can check your PowerShell version by pasting the output of $PSVersionTable here

JanPillarRubrik commented 5 years ago

Hi Jaap,

I'm using Windows 10:

PS C:\WINDOWS\system32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17134.590
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.590
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

What I think is happening is:

--> I created Credential variable and inputted: admin (username) + CarsDontFly (password).

If I use the command from SecurePasswordFile, it is using this command to convert it:

$Credential.Password | ConvertFrom-SecureString

The output is: PS C:\WINDOWS\system32> $Credential.Password | ConvertFrom-SecureString 01000000d08c9ddf0115d1118c7a00c04fc297eb01000000bc13b418a0f21c4488dee090c340c03500000000020000000000106600000001000020000000cd03c10a1e45d02c96de029a81331c26aa75c9970ce19e25db7de479368f8627000000000e8000000002000020000000eaa762d48709b97ce4305e3f6adc1c0f5aa510b1731c28e853c234f23d26387f20000000852046d612742840a70218d124da731e5cfec2b47b34c9f7f498941222d1549d40000000b07f677828163b79f61e96f60ab0cf2624c6e244a20a9608313f3ec5ecf5bed8c388b1581a3f0de2ec375862a4fc0e5d9607524804e6fd277d291e4e859ef534 PS C:\WINDOWS\system32>

If I use Export-CliXml, it is using different mechanism and even the encrypted password output is different:

`PS C:\WINDOWS\system32> $Credential | Export-CliXml -Path credentials.cred PS C:\WINDOWS\system32> cat .\credentials.cred

System.Management.Automation.PSCredential System.Object System.Management.Automation.PSCredential admin 01000000d08c9ddf0115d1118c7a00c04fc297eb01000000bc13b418a0f21c4488dee090c340c03500000000020000000000106600000001000020000000216948bebf71a9b4883a2307ccfe25a7e8ed27202d761d2029568f9469a8ce41000000000e8000000002000020000000dfa4150a2b0aa533640422bb69c05d756a25c8d6309a14a69d4764f514b0ff0f200000009b145984b11e4a1a4927eb6c89e687f2f04e0ceeabb7f955625bc37e1d52b98740000000463b5eb4722932e9e6da982e8eb4105e61852e68834098b0e48f3c43d864505d17459efa8b145676cb23e84d0ef26ffd1713429ae48de76ff708667affe3d634

PS C:\WINDOWS\system32>`

The latter can be used with Export-RubrikDatabasesJob, the first not.

Therefore, my guess is that our scripts are expecting the credentials file in XML format and including username.

clumnah commented 5 years ago

In the execution process section of the export script, it shows how to create the secure password file. It doesn’t not use this script.


From: JanPillarRubrik notifications@github.com Sent: Friday, May 24, 2019 3:59:05 AM To: rubrikinc/rubrik-scripts-for-powershell Cc: Subscribed Subject: Re: [rubrikinc/rubrik-scripts-for-powershell] Credentials file generated by Create-SecurePasswordFile.ps1 cannot be used by Rubrik PowerShell scripts (#89)

Hi Jaap,

I'm using Windows 10:

PS C:\WINDOWS\system32> $PSVersionTable

Name Value


PSVersion 5.1.17134.590 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.17134.590 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

What I think is happening is:

--> I created Credential variable and inputted: admin (username) + CarsDontFly (password).

If I use the command from SecurePasswordFile, it is using this command to convert it:

$Credential.Password | ConvertFrom-SecureString

The output is: PS C:\WINDOWS\system32> $Credential.Password | ConvertFrom-SecureString 01000000d08c9ddf0115d1118c7a00c04fc297eb01000000bc13b418a0f21c4488dee090c340c03500000000020000000000106600000001000020000000cd03c10a1e45d02c96de029a81331c26aa75c9970ce19e25db7de479368f8627000000000e8000000002000020000000eaa762d48709b97ce4305e3f6adc1c0f5aa510b1731c28e853c234f23d26387f20000000852046d612742840a70218d124da731e5cfec2b47b34c9f7f498941222d1549d40000000b07f677828163b79f61e96f60ab0cf2624c6e244a20a9608313f3ec5ecf5bed8c388b1581a3f0de2ec375862a4fc0e5d9607524804e6fd277d291e4e859ef534 PS C:\WINDOWS\system32>

If I use Export-CliXml, it is using different mechanism and even the encrypted password output is different:

PS C:\WINDOWS\system32> $Credential | Export-CliXml -Path credentials.cred PS C:\WINDOWS\system32> cat .\credentials.cred System.Management.Automation.PSCredential System.Object System.Management.Automation.PSCredential admin 01000000d08c9ddf0115d1118c7a00c04fc297eb01000000bc13b418a0f21c4488dee090c340c03500000000020000000000106600000001000020000000216948bebf71a9b4883a2307ccfe25a7e8ed27202d761d2029568f9469a8ce41000000000e8000000002000020000000dfa4150a2b0aa533640422bb69c05d756a25c8d6309a14a69d4764f514b0ff0f200000009b145984b11e4a1a4927eb6c89e687f2f04e0ceeabb7f955625bc37e1d52b98740000000463b5eb4722932e9e6da982e8eb4105e61852e68834098b0e48f3c43d864505d17459efa8b145676cb23e84d0ef26ffd1713429ae48de76ff708667affe3d634 PS C:\WINDOWS\system32>

The latter can be used with Export-RubrikDatabasesJob, the first not.

Therefore, my guess is that our scripts are expecting the credentials file in XML format and including username.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frubrikinc%2Frubrik-scripts-for-powershell%2Fissues%2F89%3Femail_source%3Dnotifications%26email_token%3DAFKMBSGEURNB5JNY5QMNVOLPW6N4TA5CNFSM4HPHWRYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWEOVKA%23issuecomment-495512232&data=02%7C01%7C%7C337aae53a890496133a808d6e01db201%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636942815472975729&sdata=DIl9QgmmxXtKoaiKweUjbO52SKM4WoX17MsK9PRfJ7o%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFKMBSDN4GCAJGDUJMLFIIDPW6N4TANCNFSM4HPHWRYA&data=02%7C01%7C%7C337aae53a890496133a808d6e01db201%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636942815472995739&sdata=K14fZPB1e2IyYH8q4pCkQJ6v3Ddnfjq3gxDTRA3X%2B5M%3D&reserved=0.

clumnah commented 5 years ago

Jaap, Please assign to me. I will update the CreateSecurePasswordFile.ps1 to be inline with the execution process of scripts.


From: Chris Lumnah chris@chrislumnah.com Sent: Friday, May 24, 2019 8:16 AM To: rubrikinc/rubrik-scripts-for-powershell; rubrikinc/rubrik-scripts-for-powershell Cc: Subscribed Subject: Re: [rubrikinc/rubrik-scripts-for-powershell] Credentials file generated by Create-SecurePasswordFile.ps1 cannot be used by Rubrik PowerShell scripts (#89)

In the execution process section of the export script, it shows how to create the secure password file. It doesn’t not use this script.


From: JanPillarRubrik notifications@github.com Sent: Friday, May 24, 2019 3:59:05 AM To: rubrikinc/rubrik-scripts-for-powershell Cc: Subscribed Subject: Re: [rubrikinc/rubrik-scripts-for-powershell] Credentials file generated by Create-SecurePasswordFile.ps1 cannot be used by Rubrik PowerShell scripts (#89)

Hi Jaap,

I'm using Windows 10:

PS C:\WINDOWS\system32> $PSVersionTable

Name Value


PSVersion 5.1.17134.590 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.17134.590 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

What I think is happening is:

--> I created Credential variable and inputted: admin (username) + CarsDontFly (password).

If I use the command from SecurePasswordFile, it is using this command to convert it:

$Credential.Password | ConvertFrom-SecureString

The output is: PS C:\WINDOWS\system32> $Credential.Password | ConvertFrom-SecureString 01000000d08c9ddf0115d1118c7a00c04fc297eb01000000bc13b418a0f21c4488dee090c340c03500000000020000000000106600000001000020000000cd03c10a1e45d02c96de029a81331c26aa75c9970ce19e25db7de479368f8627000000000e8000000002000020000000eaa762d48709b97ce4305e3f6adc1c0f5aa510b1731c28e853c234f23d26387f20000000852046d612742840a70218d124da731e5cfec2b47b34c9f7f498941222d1549d40000000b07f677828163b79f61e96f60ab0cf2624c6e244a20a9608313f3ec5ecf5bed8c388b1581a3f0de2ec375862a4fc0e5d9607524804e6fd277d291e4e859ef534 PS C:\WINDOWS\system32>

If I use Export-CliXml, it is using different mechanism and even the encrypted password output is different:

PS C:\WINDOWS\system32> $Credential | Export-CliXml -Path credentials.cred PS C:\WINDOWS\system32> cat .\credentials.cred System.Management.Automation.PSCredential System.Object System.Management.Automation.PSCredential admin 01000000d08c9ddf0115d1118c7a00c04fc297eb01000000bc13b418a0f21c4488dee090c340c03500000000020000000000106600000001000020000000216948bebf71a9b4883a2307ccfe25a7e8ed27202d761d2029568f9469a8ce41000000000e8000000002000020000000dfa4150a2b0aa533640422bb69c05d756a25c8d6309a14a69d4764f514b0ff0f200000009b145984b11e4a1a4927eb6c89e687f2f04e0ceeabb7f955625bc37e1d52b98740000000463b5eb4722932e9e6da982e8eb4105e61852e68834098b0e48f3c43d864505d17459efa8b145676cb23e84d0ef26ffd1713429ae48de76ff708667affe3d634 PS C:\WINDOWS\system32>

The latter can be used with Export-RubrikDatabasesJob, the first not.

Therefore, my guess is that our scripts are expecting the credentials file in XML format and including username.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frubrikinc%2Frubrik-scripts-for-powershell%2Fissues%2F89%3Femail_source%3Dnotifications%26email_token%3DAFKMBSGEURNB5JNY5QMNVOLPW6N4TA5CNFSM4HPHWRYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWEOVKA%23issuecomment-495512232&data=02%7C01%7C%7C337aae53a890496133a808d6e01db201%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636942815472975729&sdata=DIl9QgmmxXtKoaiKweUjbO52SKM4WoX17MsK9PRfJ7o%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFKMBSDN4GCAJGDUJMLFIIDPW6N4TANCNFSM4HPHWRYA&data=02%7C01%7C%7C337aae53a890496133a808d6e01db201%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636942815472995739&sdata=K14fZPB1e2IyYH8q4pCkQJ6v3Ddnfjq3gxDTRA3X%2B5M%3D&reserved=0.

jaapbrasser commented 5 years ago

Assigned to Chris as requested

jaapbrasser commented 5 years ago

Resolved in #93