CMD to PS formatting help. Netapp install.

Ask your 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.
This topic is 6 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

CMD to PS formatting help. Netapp install.

Post by dan.potter »

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
Last visit: Tue Sep 11, 2018 10:32 am

Re: CMD to PS formatting help. Netapp install.

Post by npilzner »

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
Last visit: Wed Nov 14, 2018 11:39 am

Re: CMD to PS formatting help. Netapp install.

Post by dan.potter »

I have to pass variables into the string so I don't thing single quotes is going to help.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: CMD to PS formatting help. Netapp install.

Post by jvierra »

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
Last visit: Wed Nov 14, 2018 11:39 am

Re: CMD to PS formatting help. Netapp install.

Post by dan.potter »

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 4783 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: CMD to PS formatting help. Netapp install.

Post by jvierra »

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
Last visit: Wed Nov 14, 2018 11:39 am

Re: CMD to PS formatting help. Netapp install.

Post by dan.potter »

Crickets over on that side :D Thanks for trying.
User avatar
dan.potter
Posts: 709
Last visit: Wed Nov 14, 2018 11:39 am

Re: CMD to PS formatting help. Netapp install.

Post by dan.potter »

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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: CMD to PS formatting help. Netapp install.

Post by jvierra »

Code: Select all

@'
1
2
3
'@ -split "`n" | scb
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: CMD to PS formatting help. Netapp install.

Post by jvierra »

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
This topic is 6 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked