FeaturedPower ShellSCCMScripts

PowerShell Pop-Up – SCCM App

i was looking to add Pop-Up message to users to close any running SQL Mgmt when deploying “SQL Server Management Studio” using SCCM.

 

I had do some research and finally come up with this script.

# add the required .NET assembly:
Add-Type -AssemblyName System.Windows.Forms
# show the MsgBox:
$result = [System.Windows.Forms.MessageBox]::Show('Please close if "SQL Mgmet Studio" is Open, then Click "Yes", click No to Cancel Installation  ', 'Info', 'YesNo', 'Warning')

 

By calling the software installation inside script will work but sccm application needs to get the Exit Code to display “installed” on Software Center.

(Start-Process -FilePath ".\SSMS-Setup-ENU.exe" -ArgumentList "/install /quiet /norestart" -Wait -Passthru).ExitCode

 

and finally i have to use Logic when user click “Yes, No”, what actions needs to implemented. Here is my Final Script.

# add the required .NET assembly:
Add-Type -AssemblyName System.Windows.Forms

# show the MsgBox:
$result = [System.Windows.Forms.MessageBox]::Show('Please close if "SQL Mgmet Studio" is Open, then Click "Yes", click No to Cancel Installation  ', 'Info', 'YesNo', 'Warning')

# check the result:
if ($result -eq 'Yes')
{
  # Call the SSMS app with silent/no restart switch with exit code  
  #.\SSMS-Setup-ENU.exe /install /quiet /norestart     actuall isntallation from CMD

  (Start-Process -FilePath ".\SSMS-Setup-ENU.exe" -ArgumentList "/install /quiet /norestart" -Wait -Passthru).ExitCode

}
else
{

  Write-Warning 'Cancelling the Installation'

}

How to Deploy a PowerShell Script using Application or Program in SCCM

For an “Application” “Deployment type” just locate this in the Program line.

For a “Package” “Program ” just place this into the CMD line.

"%Windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -Command .\Your-Scriptfilename.ps1

 

Show More

Related Articles

Back to top button