Active IQ Unified Manager Discussions

cannot map a drive on WFA from script - works from command line

stephen2
3,701 Views

Hi all, I am trying to map a drive on the wfa server from a script so I can set ntfs permissions. I am using   net use t: \\192.168.77.182\cifstest

it works from the command line.   However, when I try to run from the script, I get error 1223.  Below is what I am trying to do and relevant details below:

$ErrorArg = 'Stop'

$credentials = Get-WfaCredentials -Host 'local'

$expression = $("net use s: \\192.168.77.182\cifstest")

Get-WFALogger -Info -message $("creds: " + $credentials)

Get-WFALogger -Info -message $("Command to invoke: " + $expression)

$job = Invoke-Command -computername localhost  -credential $credentials -scriptblock {

        $output = Invoke-Expression $args[0]

       

} -argumentlist $expression -ErrorAction $ErrorArg

relevant details:

WFA service using domain admin account

svm has domain admin account in the vserver admin group

local cached credential is domain admin & password

If anyone has a known good alternate way to do this, I would be grateful for the tip

steve

3 REPLIES 3

sinhaa
3,701 Views

Can you provide some more details?

1. What is the error thrown? Place a screenshot or paste the error message.

2. WFA version

Error code 1223 is for System Error.

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

stephen2
3,701 Views

version is 2.2.0.2.4RC1   looks like a winrm problem, but I verified trustedhosts are setup for the ip address and for localhost.  Cannot use HTTPS as I dont have a certificate.      Error message below

14:42:14.168 INFO  [aa connect to share] ### Command 'aa connect to share' ###

14:42:16.773 INFO  [aa connect to share] Executing command: ./aa_connect_to_share1523475247892358711.ps1

14:42:19.223 INFO  [aa connect to share] Credentials successfully provided for 'local'

14:42:19.347 INFO  [aa connect to share] creds: System.Management.Automation.PSCredential

14:42:19.441 INFO  [aa connect to share] Command to invoke: net use s: \\192.168.77.182\cifstest

14:42:19.769 ERROR  [aa connect to share] Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Default authentication may be used with an IP address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to set TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.

14:42:19.925 ERROR  [aa connect to share] Failed executing command. Exception: Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Default authentication may be used with an IP address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to set TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.

sinhaa
3,701 Views

stephen2,

1. Let's put WFA out of picture and confirm everything works fine outside of it. You first need to confirm that winrm ( windows remote management) is properly configured for Invoke-command to work using simple commands. Open a powershell console and run this:

===

#provide the credentials here

$Creds=Get-Credential

#Now invoke-Command

Invoke-Command -ComputerName localhost -Credential $Creds -ScriptBlock { date }

====

If this doesn't print the current date, then your winrm first needs proper configuration. Until this gets to work, trying with WFA command is of no use.

winrm set winrm/config/client '@{TrustedHosts="wfa_hostname_or_IP"}'

Give the IP address instead of word localhost.

2. In a  script code, the contents inside the -scriptBlock needs to be type-casted,

$job = Invoke-Command -computername localhost  -credential $credentials -scriptblock { $output = Invoke-Expression $args[0] }

doesn't work.

See my example code here: https://communities.netapp.com/message/127151#127151

3. I don't think you need to use this Invoke-Expression inside the -scriptBlock. Once type-casted, it should b working.

sinhaa

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