Skip to content

Instantly share code, notes, and snippets.

@norbinsh
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norbinsh/994d4c00e728ed0a6c42 to your computer and use it in GitHub Desktop.
Save norbinsh/994d4c00e728ed0a6c42 to your computer and use it in GitHub Desktop.
MSI install if enough processors - env:path *Practice*
#Making sure the variables used in the script have their value set to $null before starting
$cpu = $null;
$cpupath = $null;
$msipackage = $null;
#Declaring variables
$cpupath = (gci env:\NUMBER_OF_PROCESSORS).value;
$msipackage = 'c:\users\shay\desktop\package.msi'
#Simple function to install the .MSI package if
Function Install-Package
{
msiexec /i /a $msipackage /qn
}
if ($cpupath -ge 4) #Making sure there are 4 or more processors
{
Install-Package #If true, installing the MSI package silently
}
else #If less than 4 processors, writing a warnning message and exiting
{
Write-Warning "You need to have 4 or more processors in order to install this package";
Exit-PSSession
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment