CMD to PS formatting help. Netapp install.

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
dan.potter
Posts: 709
Joined: Wed Oct 08, 2014 6:02 am

CMD to PS formatting help. Netapp install.

Post by dan.potter » Tue Sep 26, 2017 7:49 am

I need to run this command in powershell and I've tried numerous different ways. I believe PS has an issue with the quotes although it doesn't throw an error.

snapdrive7.0.exe /s /v"/qn SILENT_MODE=1 /Li SDInstall.log LPSM_SERIALNUMBER=serialnumber INSTALLDIR=\"c:\Program Files\NetApp\SnapDrive\" SVCUSERNAME=domain\username SVCUSERPASSWORD=password SVCCONFIRMUSERPASSWORD=password" SDW_WEBSRV_TCP_PORT=808 SDW_WEBSRV_HTTP_PORT=4098 TRANSPORT_PRT_SELECTION=2 TRANSPORT_PRT_PORT=80 TRANSPORT_PROTOCOL_LOGON_USERNAME=username TRANSPORT_PROTOCOL_LOGON_PASSWORD=password ESXIPADDRESS=IPaddress ESXUSERNAME=username ESXUSERPASSWORD=password ESXCONFIRMUSERPASSWORD=password ADD_WINDOWS_FIREWALL=1"

User avatar
npilzner
Posts: 5
Joined: Mon Jul 10, 2017 12:14 pm

Re: CMD to PS formatting help. Netapp install.

Post by npilzner » Tue Sep 26, 2017 10:38 am

Hey,

One quick thing I'm noticing (not sure if formatting or if it's intended) is that you are using multiple quotes within a main set. In order to accomplish this you will need to either:
  • Use two ( "" ) inside the main quotation marks, to escape the quotation mark properly.
or
  • Use single quotations ( ' ) to encapsulate the argument string
It does appear that you have an invalid number of quotations marks as well as each beginning quotation mark does not appear to have an ending quotation mark because of:

Code: Select all

SVCCONFIRMUSERPASSWORD=password"
Also I'd highly recommend calling the exe similar to this:

Code: Select all

 
$Arguments = '/s /v "/qn SILENT_MODE=1 /Li SDInstall.log LPSM_SERIALNUMBER=serialnumber INSTALLDIR=\"c:\Program Files\NetApp\SnapDrive\" SVCUSERNAME=domain\username SVCUSERPASSWORD=password SVCCONFIRMUSERPASSWORD="password" SDW_WEBSRV_TCP_PORT=808 SDW_WEBSRV_HTTP_PORT=4098 TRANSPORT_PRT_SELECTION=2 TRANSPORT_PRT_PORT=80 TRANSPORT_PROTOCOL_LOGON_USERNAME=username TRANSPORT_PROTOCOL_LOGON_PASSWORD=password ESXIPADDRESS=IPaddress ESXUSERNAME=username ESXUSERPASSWORD=password ESXCONFIRMUSERPASSWORD=password ADD_WINDOWS_FIREWALL=1"'

Start-Process snapdrive7.0.exe -ArgumentList $Arguments
If you need to wait until it finishes to return the results or utilize the information it will provide, include the optional -Wait parameter

Code: Select all

Start-Process snapdrive7.0.exe -Wait -ArgumentList $Arguments
Hope this helps!

User avatar
dan.potter
Posts: 709
Joined: Wed Oct 08, 2014 6:02 am

Re: CMD to PS formatting help. Netapp install.

Post by dan.potter » Tue Sep 26, 2017 12:33 pm

I have to pass variables into the string so I don't thing single quotes is going to help.

User avatar
jvierra
Posts: 13507
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: CMD to PS formatting help. Netapp install.

Post by jvierra » Tue Sep 26, 2017 12:47 pm

Use an array of arguments referencing the variable:

Code: Select all

$Arguments = @(
	'/s /v /qn',
	'SILENT_MODE=1',
	'/Li SDInstall.log',
	'LPSM_SERIALNUMBER=serialnumber',
	'INSTALLDIR="c:\Program Files\NetApp\SnapDrive\"',
	'SVCUSERNAME=domain\username',
	'SVCUSERPASSWORD=password',
	'SVCCONFIRMUSERPASSWORD="password"',
	'SDW_WEBSRV_TCP_PORT=808',
	'SDW_WEBSRV_HTTP_PORT=4098',
	'TRANSPORT_PRT_SELECTION=2',
	'TRANSPORT_PRT_PORT=80',
	'TRANSPORT_PROTOCOL_LOGON_USERNAME=username',
	'TRANSPORT_PROTOCOL_LOGON_PASSWORD=password',
	'ESXIPADDRESS=IPaddress',
	'ESXUSERNAME=username',
	'ESXUSERPASSWORD=password',
	'ESXCONFIRMUSERPASSWORD=password',
	'ADD_WINDOWS_FIREWALL=1'
)
Start-Process snapdrive7.0.exe -ArgumentList $Arguments
Add any variables and change single quotes to double quotes. To embed double quoutes just double or escape them

#escaped quotes
"TRANSPORT_PROTOCOL_LOGON_USERNAME=`"$username`"",

# doubled quotes:
"TRANSPORT_PROTOCOL_LOGON_USERNAME=""$username""",

User avatar
dan.potter
Posts: 709
Joined: Wed Oct 08, 2014 6:02 am

Re: CMD to PS formatting help. Netapp install.

Post by dan.potter » Tue Sep 26, 2017 1:32 pm

That doesn't work :cry: I know there is an underlying MSI and but I can't seem to get the msiexec arguments right either. Preferably I'd like to use the MSI itself as this will eventually be used in a dsc config.
Attachments
Untitled.png
Untitled.png (9.11 KiB) Viewed 1604 times

User avatar
jvierra
Posts: 13507
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: CMD to PS formatting help. Netapp install.

Post by jvierra » Tue Sep 26, 2017 2:52 pm

MSI arguments are not a scripting issue. You need to research what the MSI supports and test without PowerShell. We cannot help you with that as it is application dependent. Try posting in vendors forum for help.

User avatar
dan.potter
Posts: 709
Joined: Wed Oct 08, 2014 6:02 am

Re: CMD to PS formatting help. Netapp install.

Post by dan.potter » Tue Sep 26, 2017 2:57 pm

Crickets over on that side :D Thanks for trying.

User avatar
dan.potter
Posts: 709
Joined: Wed Oct 08, 2014 6:02 am

Re: CMD to PS formatting help. Netapp install.

Post by dan.potter » Tue Sep 26, 2017 4:18 pm

Finally got it. A single line here string did the trick. I was building a here string with all the options on a new line and the dsc config was inserting a `n after each parameter.

Alas, I still don't know why the below doesn't include the new lines.

@"
1
2
3
"@ | scb

User avatar
jvierra
Posts: 13507
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: CMD to PS formatting help. Netapp install.

Post by jvierra » Tue Sep 26, 2017 4:28 pm

Code: Select all

@'
1
2
3
'@ -split "`n" | scb

User avatar
jvierra
Posts: 13507
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: CMD to PS formatting help. Netapp install.

Post by jvierra » Tue Sep 26, 2017 4:32 pm

Also you cannot use a "here" string for an argument list. It must be a plain string or an array of strings. It cannot have line breaks embedded.

Code: Select all

@'
1
2
3
'@ -replace "`n",' '  | scb

Locked