RSS

Monthly Archives: March 2012

SCCM – Using Powershell in a Task Sequence

Using System Center Configuration Manager (SCCM),  I was trying to deploy a task sequence for lab computer imaging. I was trying to use a batch file to run a Powershell script that makes shortcuts in a specified folder, but the command prompt kept throwing an error. This error happend everytime the command prompt tried to execute the Powershell script.

Source Code

  •  Here is my source code (batch file contents).
    REM Installing  Mathematica 8
    Mathematica_8.0.4_WIN.exe /silent /suppressmsgboxes
    REM Run Shortcut Script
    powershell .\Make-Shortcuts_Mathematica8.ps1

Problem

  • When I tried to run the command:
    powershell .\Make-Shortcuts_Mathematica8.ps1
  • I get an error that states:
    File C:\workingtemp\mathematica8\Make-Shortcuts_Mathematica8.ps1 cannot be loaded. The file C:\workingtemp\mathematica8\Make-Shortcuts_Mathematica8.ps1 is not digitally signed. The script will not execute on the system. Please see “get-help about_signing” for more details..
    At line:1 char:34
    + .\Make-Shortcuts_Mathematica8.ps1 <<<<
    + CategoryInfo          : NotSpecified: (:) [], PSSecurityException
    + FullyQualifiedErrorId : RuntimeExecption 
  • The error looks like this:

Solution

  • Here is the solution, this command will work for any powershell script.
    powershell  -noprofile -command "& {$variable = Get-ExecutionPolicy:If((Get-ExecutionPolicy) -ne 'Unrestricted'){Set-ExecutionPolicy unrestricted -force;}; .\<YOURSCRIPTHERE>; Set-ExecutionPolicy $variable}"
  • This command will check if the “Execution Policy” is set to unrestricted. If not it will set it to unrestricted, then run the target powershell script. Finally, the command will set the Execution Policy back to the previous value.

Please leave a comment for any questions/problems!

 
4 Comments

Posted by on March 20, 2012 in Uncategorized

 

Tags: , , , ,

Installers and Silent Switches

This post will cover the different types of installers I’ve encountered when making automated installations in SCCM.

Installer Types

The types of installers I’ve encountered.

  1. MSI Installers
    • For setup files that use Windows Installer or Microsoft installer, use the following command-line syntax.
    • msiexec /i file.msi /qb
  2. InstallShield variant 1
    • To silently install using installshield, it is necessary to have a “answer file”. A file named “setup.iss” is configured during the record phase. All changes/additions during this manual installation phase will be recorded in the “setup.iss” file.
    • Use the command below.
      setup.exe /r
    • After running through the installation, a file called “setup.iss” will be made in your “C:\Windows” directory. Place this file in the same directory as your setup.exe.
    • Uninstall the program you just installed. This will ensure a clean install.
    • Remove “/r” and replace with “/s”, like so.
      setup.exe /s
  3. InstallShield Variant 2
    • In some versions of InstallShield different switches are used. Its always worth trying one of these commands:
      setup.exe /s
      setup.exe /silent
      setup.exe /quiet
  4. Copy the installation directory.
    • Some programs are portable enough that you can install them manually, zip the installation directory and move it to another machine
    • Use the command xcopy to copy the installation files.
    • XCOPY syntax:
      • XCOPY source [destination] [options]
      • Examples:
        xcopy putty.exe %systemroot%
        xcopy "\*.*' %systemroot%
Please leave a comment for any questions/problems!
 
2 Comments

Posted by on March 20, 2012 in Uncategorized

 

Tags: , , , , , ,

SCCM – Creating a Package

This post assumes that for the target package you have created a silent install batch file. The example application for this package is called “Putty”. If this doesn’t sound familiar, see my previous post named “SCCM Package – Putty“.

Create SCCM Package source directory

  1. First add a folder to your packages source directory. The packages source directory should be something like \\<ServerName>\<SourceDirectory>$\<Packages>\<Application>. Make the folder name the same as your application name, in my case I named the folder “Putty”.
  2. Copy your installer files and silent batch script into this new folder.

Creating the Package

  1. Open up the “ConfigMgr Console”.
  2. Expand “Site Database” on the left, then expand “Computer Management”.  Navigate to the “Software Distribution” Section. Expand this section and right click on “Packages” -> “New” -> “Package”.
  3. The “New Package Wizard” will appear. On the “General” scrren, enter a name for your package. The remainder of this page is optional.
  4. On the next screen called “Data Source”, check “This package contains source files” box. Under this option there will be another called “Source directory”, click the “Set” button to the right of the textbox. This should pop up a dialog that allows you to enter your network folder you made earlier. When finished, click “Ok” and “Next”.
  5. On the “Data Access” screen, leave everything to the defaults.
  6. On the “Distribution Settings” screen, click “Next”.
  7. On the “Reporting” screen, click “Next”.
  8. On the “Security” screen, click “Next”.
  9. On the “Summary” screen, click “Next.
  10. On the next screen called “Wizard Complete”, click “Close”.

Create the Program

  1. Navigate to your package and expand it.
  2. Right click on “Program” -> “New” -> “Program”.
  3. A screen called “New Program Wizard” will appear. Name the program “Install”. For “Command line”, enter the name of your silent install batch file. Under “Category” choose “Applications”.
  4. On the “Requirements” screen, set the estimated disk space the program will use and click “Next”.
  5. On the “Environment” screen, under “Program can run:”, select  “Whether or not a user is logged in” from the drop down menu.
  6. On the “Advanced” screen, check the box beside “Advertise this program to be installed from the Install Software task sequence without being advertised”.
  7. On the “Windows Installer” screen, I left everything to default. 
  8. On the “MOM Maintenance Mode” screen, check both boxes.
  9. On the “Summary” screen, shown is everything to be installed, hit “Next”.
  10. The program will install and finish, hit “Close”.

Manage Distribution Points

  1. In “ConfigMgr Console” find your package.
  2. Right click on the “Putty” package and choose “Manage Distribution Points”.
  3.  A screen called “Manage Distribution Points Wizard” will appear, click the “Next” button.
    \
  4. On the “Select Destination Distribution” screen, select “Copy the package to new distribution points”.
  5. On the “Package” screen. Under the “Distribution Points” section, choose “SCCM” and hit next. Do not distribute to your PXE point.
  6. Hit “Next” untill it finishes and you will be done updating the distribution points.
  7. Hit “Close” and You should be done.

Please leave a comment if you have any questions/problems!

 
1 Comment

Posted by on March 20, 2012 in Uncategorized

 

Tags:

SCCM Packages – Mathematica 8

This is a short blog post about silently installing a program that uses InstallShield silent switches. The end goal of this package will be to install a program silently or unattended on a target machine. This will allow us to automate the install on new lab machines that we recieve. For this blog we will be installing “Mathematica 8” as our example program.

Overview

  1. Figure out the silent install mechanism.
  2. Create and test a silent install script.
  3. Figure out the silent license activation mechanism.
  4. Add license configuration to install script and test.

Notes & Sites of reference:

Install your program manually

First, I will install the Mathematica 8 program manually to familiarize myself with the application and its installer. This will also tell us where the application will install to by default.

  1. If you are installing on a Virtual Machine, it is a great idea to make a snapshot before you continue.This will enable us to quickly try the silent install multiple times if needed, without having to uninstall the program each time. Sometimes uninstallers don’t remove everything. This can affect the silent install package and make you think it is working when really, the silent install package created is dependent on something that the previous installer left behind. Better to start with a clean image each test.
  2. I have a disk image of “Mathematica 8” in an “.iso” format. Using Winrar, I extracted this to a folder located at “C:\workingtemp\mathematica8”.
  3. Double click the “Mathematica_8.0.4_WIN.exe” to begin the manual installation.
  4. Hit “Next” and this menu will allow you to set the “Destination Location” for your program.
  5. For the “Select Components” screen, leave everything to default.
  6. The will pop up the “Start Menu Folder” screen, leave everything to default.
  7. Hit “Next” then “Install” and this will start its installation. When finished It should look like this.
  8. For licensing information,  it is necessary  to get the information from the company. Go to http://register.wolfram.com and enter the license and MathID and you’ll get the contents for the mathpass file back via email.
  9. To activate “Mathematica 8”, place the license file “mathpass” in the “Licensing” directory of the program. Later we will automate this process. The “Licensing” directory will be located at “C:\Program Files\Wolfram Research\Mathematica\8.0\Configuration\Licensing”.
  10. Test to see that the program is working correctly.
  11. Before testing, it would be a great idea to “revert to snapshot” on your VM.

Creating a Batch file

  • This file will install Mathematica (silently) then it will copy the licensing information to the appropriate “Licensing” directory.
  1. Create a Batch file and name it “Install-Mathematica8.cmd” and add it to “C:\workingtemp\mathematica8”.
  2. Next lets build the batch file, use the following commands in your batch file.
    REM Main Install
    Mathematica_8.0.4_WIN.exe /silent /suppressmsgboxes /log="C:\Windows\Temp\install.log"
    REM Licensing
    xcopy /y .\mathpass "C:\Program Files\Wolfram Research\Mathematica\8.0\Configuration\Licensing\"

Testing the Batch File

  1. Open a command prompt as “Administrator” and input the following command.
    cd C:\workingtemp\mathematica8
  2. Input the following command to run your batch file.
    Install-Mathematica8.cmd
  3. While the silent install is happening, it will look  like this.
  4. If the license file was properly copied, the command prompt will look like this.
  5. Check your C:\Program Files\Wolfram Research\Mathematica\8.0″ and make sure the program and its license where properly configured.
  6. The license file should be in the “Licensing” directory, like so:

You should be done.

 
1 Comment

Posted by on March 19, 2012 in Uncategorized

 

SCCM Package – Putty

This is a short blog post about installing a program silently that uses the command “xcopy”. Since Putty is a very basic program it does not install, it simply runs. The end goal of this post will be to install Putty on a target machine. This will allow us to automate the install on new lab machines that we receive.

Overview

  1. Figure out the silent install mechanism.
  2. Create and test a silent install script.

Notes & Sites of reference:

Manual installation

First, I will install the Putty program manually to to familiarize myself with the application.

  1. If you are installing on a Virtual Machine, it is a great idea to make a snapshot before you continue.This will enable us to quickly try the silent install multiple times if needed, without having to uninstall the program each time. Sometimes uninstallers don’t remove everything. This can affect the silent install package and make you think it is working when really, the silent install package created is dependent on something that the previous installer left behind. Better to start with a clean image each test.
  2. Get the installer from the Putty downloads page.
  3. Locate and double click on your “putty.exe”. A screen will pop up and click “Run”.
  4. Putty should just open.

Creating a Batch file

  1. Create a temporary directory at “C:\workingtemp\Putty” and place the “putty.exe” in this directory.
  2. Create a Batch file and name it “Install-Putty.cmd” and add it to the folder you just created..
  3. Next lets build the batch file.
    xcopy /y putty.exe %systemroot%
  4. This will simply copy the “putty.exe” to the %systemroot% folder. Usually this is C:\Windows.

Testing the Batch File

  1. Open a command prompt as “Administrator”.
  2. Change directories to “C:\workingtemp\putty” with the following command.
    cd C:\workingtemp\Putty
  3. Now run the batch file with the following command.
    Install-Putty.cmd
  4. If the installation was successful, then “putty.exe” will be in your “C:\Windows” folder.
  5. At this point you are done.
 
3 Comments

Posted by on March 19, 2012 in Uncategorized

 

SCCM Packages – ChemBioOffice

This is a short blog post about silently installing a program that uses Windows Installer or .msi files. The end goal of this post will be to install a program silently or unattended on a target machine. This will allow us to automate the install on new lab machines that we recieve. For this blog we will be installing “ChemBioOffice” as our example program.

Overview

  1. Figure out the silent install mechanism.
  2. Create and test a silent install script.
  3. Figure out the silent license activation mechanism.
  4. Add license configuration to install script and test.

Notes & Sites of reference:

Manual installation

First, I will install the ChemBioOffice program manually to to familiarize myself with the application and its installer.This will also tell us where the application will install to by default.

  1. If you are installing on a Virtual Machine, it is a great idea to make a snapshot before you continue.This will enable us to quickly try the silent install multiple times if needed, without having to uninstall the program each time. Sometimes uninstallers don’t remove everything. This can affect the silent install package and make you think it is working when really, the silent install package created is dependent on something that the previous installer left behind. Better to start with a clean image each test.
  2. Double click the “cbdu1202.exe” and the setup will start. The first menu will ask you to “have your serial number ready”, hit “OK” to continue.
  3. Immediatily after hitting “OK”, setup will start extracting files.
  4. The setup wizard will appear, followed by the “CambridgeSoft Software Activation” screen. Fill this out and click “Activate over internet”.
  5. The message box “Software Activation Complete” will appear, click “OK” to continue.
  6. Next, the  ChemBioOffice install wizard should appear. Click “Next”.
  7. Accept the license agreement and click “Next”.
  8. On the “Setup Type” screen, leave the defaults and click “Next”.
  9. On the “Select Features – CambridgeSoft” screen, uncheck the box next to “E-Notebook 12.0”, then click “Next”.
  10. On the “Select Features -Third Party” screen, uncheck the “MNova NMR Lite” option and click “Next”.
  11. On the “Ready to Install” screen, click “Install”.
  12. The installation will begin and should look similar to the following image.
  13. When finished the “Installation Complete” screen will appear, click “Finish”.
  14. Check which directory the “ChemBioOffice” program installed to.
  15. Open your “ChemBioDraw” application to see if it works. It should look similar to the screen below.

Get Licensing Information

  1. To silently register ChemBioOffice licensing information, CambridgeSoft requires that you email support fora custom registry file. At the end of the silent installation of ChemBioOffice you will import the registry file. Email Cambridge support at “activate@cambridgesoft.com” for your activation file.
  2. Save this file to your “C:\workingtemp\ChemBioOffice” folder and name it “importChemLicense.reg”

Preparing your Source Directory

  1. Make a new folder called “ChemBioMedia” at “C:\workingtemp\ChemBioMedia”.
  2. Extract the “cbdu1202.exe” file, using 7zip to C:\workingtemp\ChemBioMedia.
  3. The ChemBioMedia folder should look like this after you extract the setup file.
  4. The file tree for this folder will look like this, the objects bolded and in Italics are the files that we need.

C:\workingtemp\ChemBioMedia

  • \_images
  • \Cambridgesoft
    • \Activation
    • \ChemOffice
      • CambridgeSoft_ChemBioDraw_Ultra_12.0.msi
      • CambridgeSoft_ChemDraw_ActiveX_Enterprise_Constant_12.0.msi
    • \ENotebook
    • SharedAddIn
      • SharedAddIn.msi
  • \DatatManagement Server Setup
  • \SQLInstaller
  • \ThirdParty
  • install.exe
  • install.ini

  1. Now to make life easy copy the following code into a batch file and run it. This will put all the neccessary installer files into “C:\workingtemp\ChemBioOffice”.
    REM Copy FIles
    mkdir "C:\workingtemp\ChemBioOffice"
    xcopy /y "C:\workingtemp\ChemBioMedia\Cambridgesoft\ChemOffice\CambridgeSoft_ChemBioDraw_Ultra_12.0.msi" "C:\workingtemp\ChemBioOffice\"
    xcopy /y "C:\workingtemp\ChemBioMedia\Cambridgesoft\ChemOffice\CambridgeSoft_ChemDraw_ActiveX_Enterprise_Constant_12.0.msi" "C:\workingtemp\ChemBioOffice\"
    xcopy /y "C:\workingtemp\ChemBioMedia\Cambridgesoft\SharedAddIn\SharedAddIn.msi" "C:\workingtemp\ChemBioOffice\"
  2. Note: For my installation I needed to install only 3 parts of the ChemBioOffice. These 3 parts are; ChemBioDraw Ultra 12.0, ChemDraw ActiveX Enterprise and SharedAddIn. These and the registry file should be the only 4 things in your “C:\workingtemp\ChemBioOffice” folder.
  3. Your folder will look like this.

Creating a Batch File

  1. Navigate to your “C:\workingtemp\ChemBioOffice” folder.
  2. Create a new text document in this folder and name it  “Install_ChemBioOffice.cmd”. The ending “.cmd” will make this a batch file.
  3. Copy and paste the following commands into your batch file.
    REM Installing ChemBioOffice
    REM Main Install
    start /wait msiexec /i CambridgeSoft_ChemBioDraw_Ultra_12.0.msi /qb
    start /wait msiexec /i CambridgeSoft_ChemDraw_ActiveX_Enterprise_Constant_12.0.msi /qb
    start /wait msiexec /i SharedAddIn.msi /qb
    REM Licensing
    REGEDIT /s importChemLicense.reg

At this point your batch file should be ready to test.

Testing the batch file

  1. Navigate to “C:\workingtemp\ChemBioOffice”.
  2. Open a command prompt as “Administrator” and type the following command to change directories.
    cd C:\workingtemp\ChemBioOffice
  3. Now that we are in the correct directory type in the batch file name we are using.
    Install_ChemBioOffice.cmd
  4. Hit Enter and the installation will begin, it will look similar to the following image.
  5. Next, the application should start just as it did after the manual installation we did earlier.

If there are any problems\concerns\questions with this post, please leave a comment!

 
3 Comments

Posted by on March 16, 2012 in ChemBioOffice, SCCM

 

Tags: , , , ,