Microsoft Virtualization Discussions

connect-nccontroller without password prompt

AK_Win
4,727 Views

Hi together,

 

I'm trying to run a script (exporting shares etc.) without a password promt.

 

Our CVO 9.5P10 is domain joined and the user the powershell session is running with is set as admin on clust and svm level.

Is there a way to use the user of the Powershell session to do the login without storing the password somewhere and without having a password prompt?

 

I tried multiple things, e.g.

connect-nccontroller $server

connect-nccontroller $server -Credential $(whoami)

 

4 REPLIES 4

JGPSHNTAP
4,718 Views

Check the man pages.. Here is the full information

 


C:\PS>$password = ConvertTo-SecureString "p@ssword" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "admin",$password
Connect-NcController 10.61.172.155 -Credential $cred

Connect to controller '10.61.172.155' using HTTP/HTTPS but suppress the credential prompt by creating a PSCredential object programmatically.

 

AK_Win
4,715 Views

Yes, I read this. But this means I have to store the password one time. And I have to change this when the domain password changes.

Is there no way to use the token of the already logged in user?

mcgue
4,610 Views

Someone shared this on another post of mine.  You can pass this for the credentials.

 

#Store credentials if needed
if (!($Creds)){Set-Variable -Name Creds -Value (Get-Credential -credential "$env:userdomain\$env:username") -Scope Global -Visibility Public -Option AllScope}

 

donny_lang
4,576 Views

My recommendation would be to look at the "Add-NcCredential" cmdlet for encrypted storage of cached credentials that can be used by the PSTK. You could also use the "Credential Manager" module from the PowerShell Gallery, which provides you a method to retrieve credentials from the native Windows Credential Manager. I've used both of these options with good results in my code. 

Public