Active IQ Unified Manager Discussions

Accessing the stored credentials in WFA for Vfiler dr resync

mteeuwen
3,200 Views

How do I access the set of credentials that are stored in WFA from the PowerShell code in a command?

 

I need to do a vfiler dr resync on 7-Mode. There are no commands provided for that functionality, so I need to write it myself.

 

But the vfiler dr resync command needs to be executed on the dr filer, but then has to connect to the source filer:

Invoke-NaVfilerDrResync -RemoteVfiler $SourceVfiler -RemoteFiler $SourceFiler

 

This fails with the following error:
Parameter name: Credentials not provided in cmdlet argument or credentials cache.

 

So I need to specify the -Credential parameter. Are the WFA controller credentials accessible via a parameter?

 

2 REPLIES 2

sinhaa
3,105 Views

$Credentials = Get-WfaCredentials -HostName $myHost

 

where $myHost is the name/ip of the Host whose credentials are saved in WFA->Execution->Credentials

 

Read more about WFA cmdlets at : http://<wfa_server_name_or_ip>/wfa/wfa_docs/PoSH/docs/index.html . You can locate more documentation from WFA-> Help -> Support Links.

 

sinhaa

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

mbeattie
3,092 Views

Hi Marco,

 

The PowerShell code for the WFA command would be something like this:

 

#'------------------------------------------------------------------------------
Param(
    [parameter(Mandatory=$true, HelpMessage="The NetBIOS Hostname or IP address of the Source Controller")]
    [String]$SourceController,
    [parameter(Mandatory=$true, HelpMessage="The NetBIOS HostName or IP address of the Source Vfiler")]
    [String]$SourceVFiler
)
#'------------------------------------------------------------------------------
#'Enumerate Credentials and connect to the Source Controller
#'------------------------------------------------------------------------------
[System.Management.Automation.PSCredential]$Credentials = Get-WfaCredentials -Host $SourceController
Connect-WfaController -Array $SourceController
#'------------------------------------------------------------------------------
#'Invoke the vFiler DR Resync
#'------------------------------------------------------------------------------
Get-WFALogger -Info -Message $("Resyncing remote vfiler: " + $SourceVFiler + "@" + $SourceController)
[String]$command = "Invoke-NaVfilerDrResync -RemoteVfiler $SourceVFiler -RemoteFiler $SourceController"
Try{
    Invoke-NaVfilerDrResync -RemoteVfiler $SourceVFiler -RemoteFiler $SourceController -Credential $Credentials -Confirm:$False
   Get-WFALogger -Info -Message "Executed $command"
}Catch{
    [String]$errorMessage = $error[0].Exception.Message
    Get-WFALogger -Error -Message "Failed Executing $command. $errorMessage"
    Throw "Failed Executing $command. $errorMessage"
}
#'------------------------------------------------------------------------------

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
Public