Question:
I am trying to install Notepad++ software using a PowerShell v2.0 script for one of my POC. I need to install the client’s software in my current project. As I am running the below script I’m getting errors.
1 2 3 4 |
Start-Process 'C:\Users\kirnen\Desktop\A\npp.7.5.Installer.exe'-InstallerParameters "/S" ` -RegistryKey HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Notepad++ ` -RegistryName DisplayVersion -RegistryValue 7.5 |
As I am very much new to powershell scripting, can you please help in this? Is the above code right, or do I need to change anything else to install the software?
Answer:
I use this snippet of PowerShell code for a lot of installs. As long as you can figure out the silent switch for “.exe’s”. For “.msi’s” just change out where Create()
with Create("msiexec /I C:\temp\generic.msi /qn")
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$computers = c:\temp\computerName.csv $Notepad = "Location of notepad install" $computers | where{test-connection $_ -quiet -count 1} | ForEach-Object { copy-item $Notepad -recurse "\\$_\c$\temp" $newProc=([WMICLASS]"\\$_\root\cimv2:win32_Process").Create("C:\temp\npp.6.9.2.Installer.exe /S") If ($newProc.ReturnValue -eq 0) { Write-Host $_ $newProc.ProcessId } else { write-host $_ Process create failed with $newProc.ReturnValue } } |