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"
CMD to PS formatting help. Netapp install.
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.
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.
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: CMD to PS formatting help. Netapp install.
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:
Also I'd highly recommend calling the exe similar to this:
If you need to wait until it finishes to return the results or utilize the information it will provide, include the optional -Wait parameter
Hope this helps!
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.
- Use single quotations ( ' ) to encapsulate the argument string
Code: Select all
SVCCONFIRMUSERPASSWORD=password"
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
Code: Select all
Start-Process snapdrive7.0.exe -Wait -ArgumentList $Arguments
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: CMD to PS formatting help. Netapp install.
I have to pass variables into the string so I don't thing single quotes is going to help.
Re: CMD to PS formatting help. Netapp install.
Use an array of arguments referencing the variable:
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""",
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
#escaped quotes
"TRANSPORT_PROTOCOL_LOGON_USERNAME=`"$username`"",
# doubled quotes:
"TRANSPORT_PROTOCOL_LOGON_USERNAME=""$username""",
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: CMD to PS formatting help. Netapp install.
That doesn't work 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 (9.11 KiB) Viewed 4800 times
Re: CMD to PS formatting help. Netapp install.
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.
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: CMD to PS formatting help. Netapp install.
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
Alas, I still don't know why the below doesn't include the new lines.
@"
1
2
3
"@ | scb
Re: CMD to PS formatting help. Netapp install.
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