NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

Active IQ Unified Manager Discussions

WFA 2.1 interpret var with "$" in text as nul

francoisbnc
4,002 Views

Hi,

I created kind type of command to stop remote SQL service that worked fine in wfa 2.01

$MachineName = 'gdc01172'

$Instance = 'SGEDYNT1'

$Service =  'MSSQL$'+$Instance

(get-service -ComputerName $MachineName -Name  $Service).stop()

It works fine in PS debugger, however in WFA 2.1  $Service is viewed as null and workflow crash with error

***in Powershell_ISE

PS C:\Users\itsfe> $MachineName = 'gdc01172'

$Instance = 'SGEDYNT1'

$Service =  'MSSQL$'+$Instance

(get-service -ComputerName $MachineName -Name  $Service)

Status   Name               DisplayName                          

------   ----               -----------                          

Running  MSSQL$SGEDYNT1     SQL Server (SGEDYNT1)     

**in WFA

16:37:51.779 INFO  [_start_stop_SQL] Error: You cannot call a method on a null-valued expression.

Is somebody experience the same with $ char or is $ is treated differently from 2.1 version?

Help appreciated

francois

1 ACCEPTED SOLUTION

sinhaa
4,002 Views

francois,

     I don't think there has been any change with this regard since WFA2.0.1.

I tried a similar but not the exact scenario on WFA 2.1 and I didn't face any problems

I created a dummy windows service with name NA_WFA_$DB on my WFA server and used a command to call the following.

On powershell I was getting this:

PS C:\Users\Administrator> Get-Service -ComputerName localhost -Name 'NA_WFA_$DB'

Status   Name               DisplayName

------   ----               -----------

Stopped  NA_WFA_$DB         NA_WFA_$DB

PS C:\Users\Administrator>

-----

On WFA command, I added a snippet

-----

part1='DB'

part2='NA_WFA_$' + part1

$Service_name= 'sinhaa' + (Get-Service -ComputerName localhost -Name $part2).Name

-----

This passed in execution for me. $Service_name gave sinhaaNA_WFA_$DB

This means even with the presence of $ in the Name, my execution was successful and it didn't return a null object.

Are you still facing the issue?

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

View solution in original post

2 REPLIES 2

sinhaa
4,003 Views

francois,

     I don't think there has been any change with this regard since WFA2.0.1.

I tried a similar but not the exact scenario on WFA 2.1 and I didn't face any problems

I created a dummy windows service with name NA_WFA_$DB on my WFA server and used a command to call the following.

On powershell I was getting this:

PS C:\Users\Administrator> Get-Service -ComputerName localhost -Name 'NA_WFA_$DB'

Status   Name               DisplayName

------   ----               -----------

Stopped  NA_WFA_$DB         NA_WFA_$DB

PS C:\Users\Administrator>

-----

On WFA command, I added a snippet

-----

part1='DB'

part2='NA_WFA_$' + part1

$Service_name= 'sinhaa' + (Get-Service -ComputerName localhost -Name $part2).Name

-----

This passed in execution for me. $Service_name gave sinhaaNA_WFA_$DB

This means even with the presence of $ in the Name, my execution was successful and it didn't return a null object.

Are you still facing the issue?

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

francoisbnc
4,002 Views

I retried and that worked now, I don't know what is spent.

My service SQL is successfully stopped with service name.


Public