Mick's IT Blogs

Mick's IT Blogs

19 July 2013

Powershell: Reset Network Adaptor with Connectivity Verification

Posted By: Mick Pletcher - 10:27 AM
Here is a script that will disable and then re-enable the network interface on your pc. It will also verify if the network connection is re-established by testing the connection to google.com.


 cls  
 #Declare Global Variables  
 Set-Variable -Name Computer -Scope Global -Force  
 Set-Variable -Name Active -Scope Global -Force  
 Set-Variable -Name Network -Scope Global -Force  
 Set-Variable -Name Networks -Scope Global -Force  
 Set-Variable -Name Output -Scope Global -Force  
 Set-Variable -Name RetVal -Scope Global -Force  
 $Computer = gc env:computername  
 $Networks = Get-WmiObject Win32_NetworkAdapter -ComputerName $Computer  
 Foreach ($Network in $Networks) {  
      If ($Network.NetEnabled -eq $true) {  
           $Active = $Network  
           Write-Host "Network Adaptor"  
           Write-host "   "$Network.Description  
           Write-Host  
           $RetVal = $Network.Disable()  
           If ($RetVal.ReturnValue -eq 0) {  
                Write-Host "Network adaptor is disabled"  
           }  
           Start-Sleep -Seconds 5  
           $RetVal = $Network.Enable()  
           If ($RetVal.ReturnValue -eq 0) {  
                Write-Host "Network adaptor is re-enabled"  
           }  
           Start-Sleep -Seconds 30  
           $Output = Test-Connection google.com -Quiet  
           If ($Output -eq $true) {  
                Write-Host "Network adaptor Restored"  
           } else {  
                Write-Host "Network adaptor unavailable"  
           }  
      }  
 }  
 Remove-Variable -Name Active -Scope Global -Force  
 Remove-Variable -Name Computer -Scope Global -Force  
 Remove-Variable -Name Network -Scope Global -Force  
 Remove-Variable -Name Networks -Scope Global -Force  
 Remove-Variable -Name Output -Scope Global -Force  
 Remove-Variable -Name RetVal -Scope Global -Force  

18 July 2013

SCCM: Deploying Autodesk Revit 2013

Posted By: Mick Pletcher - 2:04 PM
In order to deploy the Revit 2013 through SCCM, you will need to have the detection method setup. I used the msi product codes listed below. This is the complete list of all the applications that Revit Building Premium installs in the exact order as listed below. I entered all of the msi product codes below just to make sure the package was completely installed before SCCM marked it as successful.

For the deployment script, I used the VBScript I wrote, listed below, to install the package. I had to write a VBScript to install Revit because setup.exe opens up another instance of itself and then closes the original instance. This causes SCCM and MDT to think that it has completed, when it has not. The script pauses for several seconds and then looks for the setup.exe again to get around this. The script will also run from any location, as I have it to use the relative path at when it was executed from.

You can download the script from here.

Autodesk® Design Review 2013
{153DB567-6FF3-49AD-AC4F-86F8A3CCFDFB}

Autodesk® Revit® 2013
{7346B4A0-1300-0510-0409-705C0D862004}

AutoCAD® 2013
{5783F2D7-B001-0000-0102-0060B0CE6BBA}

Autodesk® Navisworks® Simulate 2013
{F17E30E2-7ED4-0000-8A8E-CAB597E3F8ED}

Autodesk® 3ds Max® Design 2013
{7D65612F-53B4-0409-85AA-21DF5A8E9455}

Autodesk® Showcase® 2013
{A15BFC7D-6A90-47E6-8C6E-D51B2929D8C8}

AutoCAD® Architecture 2013
{5783F2D7-B004-0000-0102-0060B0CE6BBA}

Autodesk® SketchBook® Designer 2013
{3CB60177-D3D2-4E9C-BE4D-8372B34B4C7F}

Autodesk® Inventor® Fusion 2013
{FFF5619F-2013-0064-A85E-9994F70A9E5D}

Autodesk® SketchBook® Designer for AutoCAD® 2013
{7B42AD25-3D13-4422-A445-F5E18BD963FC}

Autodesk Material Library 2013 - Medium Image Library
{58760EEC-8B6A-43F4-81AA-696E381DFADD}

Autodesk® Backburner 2013
{3D347E6D-5A03-4342-B5BA-6A771885F379}

Autodesk Inventor Server Engine For 3ds Max Design 2013
{BC66B242-DF13-1664-851B-00123612ED98}

3dsMax Composite 2013
{2F808931-D235-4FC7-90CD-F8A890C97B2F}

Autodesk® Revit Interoperability for 3ds Max 2013
{06E18300-BB64-1664-8E6A-2593FC67BB74}

Autodesk® Civil View 2013
{FE6DCC8D-427F-405C-A779-C93B6D9F77A5}

Autodesk® Essential Skills Movies for 3dsMax Design 2013
{62CBE596-1BB8-4D7B-A056-103287BAD1C4}

Autodesk Cloud sync
{EE5F74BC-5CD5-4EF2-86BA-81E6CF46A18F}


 '*******************************************************************************  
 '   Author: Mick Pletcher  
 '    Date: 20 November 2012  
 '  Modified:  
 '  
 ' Description: This will install Revit 2013  
 '*******************************************************************************  
 Option Explicit  
 REM Define Global Variables  
 DIM Architecture : Set Architecture = Nothing  
 DIM INIFile    : INIFile     = "bldg_premium_full_Relative.ini"  
 DIM InstallFile  : InstallFile   = "setup.exe"  
 DIM TempFolder  : TempFolder    = "c:\temp\"  
 DIM LogFolderName : LogFolderName  = "bldg_premium_full"  
 DIM LogFolder   : LogFolder    = TempFolder & LogFolderName & "\"  
 DIM NewformaExist : NewformaExist  = False  
 DIM RelativePath : Set RelativePath = Nothing  
 REM Define the relative installation path  
 DefineRelativePath()  
 REM Disable File Security Warning  
 DisableWarning()  
 REM Map Drive Letter  
 MapDrive()  
 REM Create the Log Folder  
 CreateLogFolder()  
 REM Install RAC  
 InstallRevit()  
 REM Enable File Security Warning  
 EnableWarning()  
 REM Cleanup Global Memory  
 GlobalMemoryCleanup()  
 '*******************************************************************************  
 '*******************************************************************************  
 Sub DefineRelativePath()  
      REM Get File Name with full relative path  
      RelativePath = WScript.ScriptFullName  
      REM Remove file name, leaving relative path only  
      RelativePath = Left(RelativePath, InStrRev(RelativePath, "\"))  
 End Sub  
 '*******************************************************************************  
 Sub MapDrive()  
      REM Define Local Objects  
      DIM oShell : SET oShell = CreateObject("Wscript.Shell")  
      REM Define Local Variables  
      DIM DeleteDrive  : DeleteDrive  = "net use z: /delete /Y"  
      DIM MapDriveLetter : MapDriveLetter = "net use z:" & Chr(32) & Left(RelativePath, InStrRev(RelativePath, "\")-1)  
      oShell.Run DeleteDrive, 1, True  
      oShell.Run MapDriveLetter, 1, True  
      RelativePath = "z:\"  
      REM Cleanup Local Variables  
      Set DeleteDrive  = Nothing  
      Set MapDriveLetter = Nothing  
      Set oShell     = Nothing  
 End Sub  
 '*******************************************************************************  
 Sub CreateLogFolder()  
      REM Define Local Objects  
      DIM FSO : Set FSO = CreateObject("Scripting.FileSystemObject")  
      If NOT FSO.FolderExists(TempFolder) then  
           FSO.CreateFolder(TempFolder)  
      End If  
      If NOT FSO.FolderExists(LogFolder) then  
           FSO.CreateFolder(LogFolder)  
      End If  
      REM Cleanup Local Variables  
      Set FSO = Nothing  
 End Sub  
 '*******************************************************************************  
 Sub DetermineArchitecture()  
      REM Define Local Objects  
      DIM WshShell : Set WshShell = CreateObject("WScript.Shell")  
      REM Define Local Variables  
      DIM OSType : OSType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")  
      If OSType = "x86" then  
           Architecture = "x86"  
      elseif OSType = "AMD64" then  
           Architecture = "x64"  
      end if  
      REM Cleanup Local Memory  
      Set WshShell = Nothing  
      Set OSType  = Nothing  
 End Sub  
 '*******************************************************************************  
 Sub CheckFreeSpace()  
      REM Define Local Objects  
      DIM oShell : Set oShell = CreateObject( "WScript.Shell" )  
      REM Define Local Variables  
      DIM strComputer : strComputer = "."  
      DIM SystemDrive : SystemDrive = oShell.ExpandEnvironmentStrings("%SystemDrive%")  
      Set objWMIService = GetObject("winmgmts:" _  
           & "{impersonationLevel=impersonate}!\\" _  
           & strComputer & "\root\cimv2")  
      Set colDisks = objWMIService.ExecQuery _  
           ("Select * from Win32_LogicalDisk")  
      For Each objDisk in colDisks  
           If objDisk.DeviceID = SystemDrive then  
                Wscript.Echo "DeviceID: " & objDisk.DeviceID  
                Wscript.Echo "Free Disk Space: " _  
                     & objDisk.FreeSpace  
           End If  
      Next  
      REM Cleanup Local Memory  
      Set oShell   = Nothing  
      Set strComputer = Nothing  
      Set SystemDrive = Nothing  
 End Sub  
 '*******************************************************************************  
 Sub DisableWarning()  
      REM Define Local Objects  
      DIM oShell : Set oShell= CreateObject("Wscript.Shell")  
      DIM oEnv  : Set oEnv = oShell.Environment("PROCESS")  
      oEnv("SEE_MASK_NOZONECHECKS") = 1  
      REM Cleanup Memory  
      Set oShell = Nothing  
      Set oEnv  = Nothing  
 End Sub  
 '*******************************************************************************  
 Sub EnableWarning()  
      REM Define Local Objects  
      DIM oShell : Set oShell= CreateObject("Wscript.Shell")  
      DIM oEnv  : Set oEnv = oShell.Environment("PROCESS")  
      oEnv.Remove("SEE_MASK_NOZONECHECKS")  
      REM Cleanup Memory  
      Set oShell = Nothing  
      Set oEnv  = Nothing  
 End Sub  
 '*******************************************************************************  
 Sub InstallCpp()  
      REM Define Local Objects  
      DIM oShell : SET oShell = CreateObject("Wscript.Shell")  
      REM Define Local Variables  
      DIM Switches : Switches = Chr(32) & "/passive /uninstall /norestart /log" & Chr(32) & LogFolder & "InstallC++.log"  
      DIM Install : Install = RelativePath & "AdminImage\3rdParty\x86\VCRedist\2010\vcredist_x86_NEW.exe" & Switches  
      DIM NoWait  : NoWait  = False  
      DIM Wait   : Wait   = True  
      oShell.Run Install, 1, True  
      REM Cleanup Local Memory  
      Set Switches = Nothing  
      Set Install = Nothing  
      Set NoWait  = Nothing  
      Set oShell  = Nothing  
      Set Wait   = Nothing  
 End Sub  
 '*******************************************************************************  
 Sub UninstallCpp()  
      REM Define Local Objects  
      DIM oShell : SET oShell = CreateObject("Wscript.Shell")  
      REM Define Local Variables  
      DIM Switches  : Switches  = Chr(32) & "/passive /uninstall /norestart /log" & Chr(32) & LogFolder & "UninstallC++.log"  
      DIM Uninstall01 : Uninstall01 = RelativePath & "AdminImage\3rdParty\x86\VCRedist\2010\vcredist_x86.exe" & Switches  
      DIM Uninstall02 : Uninstall02 = RelativePath & "AdminImage\3rdParty\x86\VCRedist\2010\vcredist_x86_NEW.exe" & Switches  
      DIM NoWait   : NoWait = False  
      DIM Wait    : Wait  = True  
      oShell.Run Uninstall01, 1, True  
      oShell.Run Uninstall02, 1, True  
      REM Cleanup Local Memory  
      Set Switches  = Nothing  
      Set Uninstall01 = Nothing  
      Set Uninstall02 = Nothing  
      Set NoWait   = Nothing  
      Set oShell   = Nothing  
      Set Wait    = Nothing  
 End Sub  
 '*******************************************************************************  
 Sub InstallRevit()  
      REM Define Local Objects  
      DIM oShell : SET oShell = CreateObject("Wscript.Shell")  
      REM Define Local Variables  
      DIM Switches : Switches = Chr(32) & "/qb /I" & Chr(32) & RelativePath & "AdminImage\" & INIFile & Chr(32) & "/language en-us"  
      DIM Install : Install = RelativePath & "AdminImage\" & InstallFile & Switches  
      DIM NoWait  : NoWait  = False  
      DIM Wait   : Wait   = True  
      oShell.Run Install, 1, True  
      Call WaitForInstall()  
      REM Cleanup Local Variables  
      Set Install = Nothing  
      Set NoWait  = Nothing  
      Set oShell  = Nothing  
      Set Switches = Nothing  
      Set Wait   = Nothing  
 End Sub  
 '*******************************************************************************  
 Sub WaitForInstall()  
      REM Define Local Constants  
      CONST Timeout = 3000  
      CONST Timepoll = 500  
      REM Define Local Variables  
      DIM sQuery : sQuery = "select * from win32_process where name=" & Chr(39) & InstallFile & Chr(39)  
      DIM SVC  : Set SVC = GetObject("winmgmts:root\cimv2")  
      REM Define Local Variables  
      DIM cproc  : Set cproc  = Nothing  
      DIM iniproc : Set iniproc = Nothing  
      REM Wait until Second Setup.exe closes  
      Wscript.Sleep 30000  
      Set cproc = svc.execquery(sQuery)  
      iniproc = cproc.count  
      Do While iniproc = 1  
           wscript.sleep 5000  
           set svc=getobject("winmgmts:root\cimv2")  
           sQuery = "select * from win32_process where name=" & Chr(39) & InstallFile & Chr(39)  
           set cproc=svc.execquery(sQuery)  
           iniproc=cproc.count  
      Loop  
      REM Cleanup Local Variables  
      Set cproc  = Nothing  
      Set iniproc = Nothing  
      Set sQuery = Nothing  
      set SVC   = Nothing  
 End Sub  
 '*******************************************************************************  
 Sub GlobalMemoryCleanup()  
      REM Define Local Objects  
      DIM oShell : SET oShell = CreateObject("Wscript.Shell")  
      REM Define Local Variables  
      DIM DeleteDrive : DeleteDrive = "net use z: /delete /Y"  
      oShell.Run DeleteDrive, 1, True  
      Set Architecture = Nothing  
      Set INIFile    = Nothing  
      Set InstallFile  = Nothing  
      Set LogFolder   = Nothing  
      Set LogFolderName = Nothing  
      Set RelativePath = Nothing  
      Set TempFolder  = Nothing  
      REM Cleanup Local Memory  
      Set DeleteDrive = Nothing  
      Set oShell   = Nothing  
 End Sub  

16 July 2013

SCCM: Initiate Hardware Inventory from an application package

Posted By: Mick Pletcher - 2:13 PM
You have setup an application package and want to initiate a hardware inventory immediately after the software is installed. Here is a powershell script that will initiate the hardware inventory, verify it was initiated and return an error code 0 if initiated back to SCCM. This allows the hardware inventory to become an application with a return value to look for by injecting the script in as a custom script as the detection method.

You can download the script from here to inject into SCCM.


 Clear-Host  
 Set-Variable -Name a -Scope Global -Force  
 Set-Variable -Name SMSCli -Scope Global -Force  
 $SMSCli = [wmiclass] "root\ccm:SMS_Client"  
 $a = $SMSCli.TriggerSchedule("{00000000-0000-0000-0000-000000000001}")  
 If ($a.__PROPERTY_COUNT -eq 1) {  
      $SMSCli.Dispose  
      Remove-Variable -Name a -Scope Global -Force  
      Remove-Variable -Name SMSCli -Scope Global -Force  
      exit 0  
 } else {  
      $SMSCli.Dispose  
      Remove-Variable -Name a -Scope Global -Force  
      Remove-Variable -Name SMSCli -Scope Global -Force  
      exit 1  
 }  

Powershell: Autodesk Revit 2013 Building Premium Uninstall Script

Posted By: Mick Pletcher - 1:31 PM
Here is a script I have written that will uninstall Revit 2013 Building Premium. Autodesk provides the Design Suite uninstall tool, but it does not uninstall all of the components. This script I have written does.

You can download the script from here.

 cls  
 Function AutoCAD2013English{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{5783F2D7-B001-0000-0102-0060B0CE6BBA}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "AutoCAD 2013 - English"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskRevitInteroperabilityfor3dsMaxand3dsMaxDesign201364-bit{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{06E18300-BB64-1664-8E6A-2593FC67BB74}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Revit Interoperability for 3ds Max and 3ds Max Design 2013 64-bit"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskShowcase201364-bit{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{A15BFC7D-6A90-47E6-8C6E-D51B2929D8C8}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Showcase 2013 64-bit"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskDirectConnect201364-bit{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{324297F8-2898-454B-9AC4-07050AEB35B3}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk DirectConnect 2013 64-bit"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskSketchBookDesigner2013{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{3CB60177-D3D2-4E9C-BE4D-8372B34B4C7F}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk SketchBook Designer 2013"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskDesignReview201332-bit{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{153DB567-6FF3-49AD-AC4F-86F8A3CCFDFB}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Design Review 2013 *32-bit*"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskInventorFusion2013{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{FFF5619F-2013-0064-A85E-9994F70A9E5D}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Inventor Fusion 2013"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskMaterialLibrary201332-bit{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{117EBEEB-5DB0-43C8-9FD6-DD583DB152DD}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Material Library 2013 *32-bit*"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskMaterialLibraryBaseResolutionImageLibrary2013{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{606E12B9-641F-4644-A22A-FF38AE980AFD}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Material Library Base Resolution Image Library 2013"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskMaterialLibraryLowResolutionImageLibrary2013{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{27C6C0A2-2EC9-4FEA-BE2B-659EAAC2C68C}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Material Library Low Resolution Image Library 2013"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskMaterialLibraryMediumResolutionImageLibrary2013{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{58760EEC-8B6A-43F4-81AA-696E381DFADD}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Material Library Medium Resolution Image Library 2013"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskContentService{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{62F029AB-85F2-0000-866A-9FC0DD99DDBC}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Content Service"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskSync{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{EE5F74BC-5CD5-4EF2-86BA-81E6CF46A18F}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Sync"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskRevit2013{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{7346B4A0-1300-0510-0409-705C0D862004}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Revit 2013"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutoCADArchitecture2013{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{5783F2D7-B004-0000-0102-0060B0CE6BBA}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "AutoCAD Architecture 2013"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskNavisworksSimulate2013{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{F17E30E2-7ED4-0000-8A8E-CAB597E3F8ED}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Navisworks Simulate 2013"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskWorkflowsBuildingDesignSuite2013{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{06388E0D-A364-478B-8E40-7D76142A8DF2}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Workflows - Building Design Suite 2013"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskNavisworksSimulate20132008DWGFileReader{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{4F744A9A-3067-4605-8864-DA1658059F0B}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Navisworks Simulate 2013 - 2008 DWG File Reader"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskNavisworksSimulate20132009DWGFileReader{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{07DC9A9D-1793-4EB4-AC1A-70750F9FB72B}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Navisworks Simulate 2013 - 2009 DWG File Reader"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskNavisworksSimulate20132010DWGFileReader{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{0D53A298-B2B7-4746-BB92-B757A6E559C3}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Navisworks Simulate 2013 - 2010 DWG File Reader"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskNavisworksSimulate20132011DWGFileReader{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{107CB1E9-DDA9-40B5-8A6D-325361402200}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Navisworks Simulate 2013 - 2011 DWG File Reader"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function Revit2013LanguagePackEnglish{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{7346B4A0-1300-0511-0409-705C0D862004}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Revit 2013 Language Pack - English"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskNavisworksSimulate20132012DWGFileReader{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{90A2F9D3-3E5E-4EF4-BC83-E7795CEF1A42}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Navisworks Simulate 2013 - 2012 DWG File Reader"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskNavisworksSimulate20132013DWGFileReader{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{CBED6FC7-FB20-4920-AA80-3D6F3459F902}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Navisworks Simulate 2013 - 2013 DWG File Reader"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskNavisworksSimulate2013EnglishLanguagePack{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{F17E30E2-7ED4-0409-8A8E-CAB597E3F8ED}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Navisworks Simulate 2013 English Language Pack"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 Function AutodeskSimulationCFD2013{  
      #Declare Local Memory  
      Set-Variable -Name GUID -Value "{1C11BFF1-1FA3-4AA9-AA15-9AA2BB921F9E}" -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Write-Host "Autodesk Simulation CFD 2013"  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      #Cleanup Local Memory  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
 }  
 #Covers all apps the ADSUninstallTool.exe uninstalls  
 AutoCAD2013English  
 AutodeskRevitInteroperabilityfor3dsMaxand3dsMaxDesign201364-bit  
 AutodeskShowcase201364-bit  
 AutodeskDirectConnect201364-bit  
 AutodeskSketchBookDesigner2013  
 AutodeskDesignReview201332-bit  
 AutodeskInventorFusion2013  
 AutodeskMaterialLibrary201332-bit  
 AutodeskMaterialLibraryBaseResolutionImageLibrary2013  
 AutodeskMaterialLibraryLowResolutionImageLibrary2013  
 AutodeskMaterialLibraryMediumResolutionImageLibrary2013  
 AutodeskContentService  
 AutodeskSync  
 #Uninstalls the ADSUninstallTool.exe does not uninstall  
 AutodeskRevit2013  
 AutoCADArchitecture2013  
 AutodeskNavisworksSimulate2013  
 AutodeskWorkflowsBuildingDesignSuite2013  
 AutodeskNavisworksSimulate20132008DWGFileReader  
 AutodeskNavisworksSimulate20132009DWGFileReader  
 AutodeskNavisworksSimulate20132010DWGFileReader  
 AutodeskNavisworksSimulate20132011DWGFileReader  
 Revit2013LanguagePackEnglish  
 AutodeskNavisworksSimulate20132012DWGFileReader  
 AutodeskNavisworksSimulate20132013DWGFileReader  
 AutodeskNavisworksSimulate2013EnglishLanguagePack  
 AutodeskSimulationCFD2013  

15 July 2013

Powershell: How to verify if a Windows Feature is enabled or disabled in a script

Posted By: Mick Pletcher - 4:01 PM
I recently wanted to add the feature to MDT to be able to verify if a Windows feature is enabled or disabled, and then write a registry key for MDT. This is an example I use here to disable MediaCenter in Windows 7 and then register that in Add/Remove Programs.


 cls  

 #Declare Global Memory  
 Set-Variable -Name a -Scope Global -Force  
 Set-Variable -Name Output -Scope Global -Force  

 Function AddRemovePrograms($KeyName, $DisplayName, $Version){  
      #Declare Local Memory  
      Set-Variable -Name AddRemKey -Value "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" -Scope Local -Force  

      New-Item -Path $AddRemKey -Name $KeyName –Force  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayName -Value $DisplayName -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayVersion -Value $Version -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name UninstallString -Value " " -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name Publisher -Value "Gresham, Smith and Partners" -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayIcon -Value "c:\windows\GSPBox_Icon.bmp" -PropertyType String  

      #Cleanup Local Memory  
      Remove-Variable -Name AddRemKey -Scope Local -Force  
 }  
 Invoke-Command {dism.exe /online /disable-feature /featurename:MediaCenter /norestart}  
 $a = Invoke-Command {dism.exe /online /get-featureinfo /featurename:MediaCenter}  
 $Output = $a | Select-String "State : Disabled"  
 Write-Host $Output  
 If ($Output -like "State : Disabled"){  
      AddRemovePrograms "MediaCenter" "MediaCenter" "Disabled"  
 }  

 #Cleanup Global Memory  
 Remove-Variable -Name a -Scope Global -Force  
 Remove-Variable -Name Output -Scope Global -Force  

02 July 2013

SCCM: Properties Window Follows Mouse

Posted By: Mick Pletcher - 1:08 PM
This was an observation I noticed today. If you have multiple monitors, when you open up the properties window of an SCCM object, the window will open up on the monitor that your cursor is residing. 

01 July 2013

SCCM: How to export a list of machines from the Deployment Status Window

Posted By: Mick Pletcher - 1:46 PM
Sometimes when checking the status of a deployment, you will need to export a list of machines from one of the asset details list. In the SCCM deployment status  window, it is not possible. In order to export the list, you will need to go to the reports section, where exporting is available. Take this deployment I was doing for instance. There were 11 machines that failed the evaluation phase. I needed the list of machines from that report to run a powershell script to see if the hotfix was installed or not. I was going to run the script through psexec against a text file containing that list of machines. 


In order to export the list of machines, you will need to go to Reporting. I use the web based reporting. Under Reporting, click on Software Distribution - Application Monitoring--->All application deployments. Populate the fields to match the collection you are wishing to export. This will match the Deployments Status in the console. Once you have pulled the report up, click on View Current Data. Under the next window, click on the Total Number of Errors, for instance. Next, click on the assets field to select the report to export. This is where you can now export the list of machines.

Copyright © 2013 Mick's IT Blogs™ is a registered trademark.