Month: June 2013

Denver Microsoft UG – MVP Expert Panel 6/28/13

Posted on Updated on

Vote for attendance can be completed at http://memug.wordpress.com/2013/06/14/june-memug-rsvp/

MEMUG_Expert_Panel_2013_Flyer

Advertisement

Deploying Microsoft Hotfixes via the ConfigMgr 2012 App Model

Posted on

In this example, I will use the new ConfigMgr 2012 application model to deploy the a Microsoft hotfix.  While this is not intended to be a full demo on how to create a script installer for the application model, this will feature a few key components — the installation/uninstallation command lines and then using PowerShell to detect the presence of the hotfix’s installation status.

For the install/uninstall command lines, be certain to NOT call the .wsu installer directly as this will fail with message “Method EnforceApp failed with error 87d01104” in the AppDiscovery.log file.  Rather, use wusa.exe to trigger the install.  Also, ensure the file name is surrounded by double quotes and the appropriate parameters are added after the quotes.

  • Install – wusa.exe “KB1234567” /quiet
  • Uninstall – wusa.exe “KB1234567” /uninstall

wusa_kb_inst

For the detection logic (in the Deployment Type), select to use script type “PowerShell” and click edit.  For the script contents, run command


Get-HotFix | Where-Object {$_.HotfixID -eq 'KB1234567'}

ps_detect_kb

 

And this should be the main components you need to have in place to successfully detect and deploy a hotfix with the ConfigMgr 2012 as an Application!

VBScript to Disable Devices with Devcon

Posted on Updated on

The following VBScript can be used as an example for disabling devices with Microsoft’s devcon utility.

'==========================================================================
' NAME: DisableWifi
' AUTHOR: Nick Moseley, https://t3chn1ck.wordpress.com
' COMMENT: Determines if a network adapter device is wireless/wifi and then
' executes a devcon command to disable the device
' VERSION HISTORY:
' 1.0 (05/13/2011) - Initial Script
' 2.0 (05/25/2011) - Added logging into registry for future inventory
'==========================================================================
Option Explicit
Const ForAppending = 8

Dim oWMI, oShell, colItems, oFSO, oFile
Set oShell = CreateObject ("WScript.Shell")
Set oWMI = GetObject ("winmgmts:\\.\root\cimv2")
Set colItems = oWMI.ExecQuery ("Select * from Win32_PnPEntity where name like '%wireless%' or name like '%wifi %'")

'Start logging
Set oFSO = CreateObject("Scripting.fileSystemObject")
Set oFile = oFSO.OpenTextFile ("C:\Windows\Temp\WifiLog.txt", ForAppending, True)
oFile.WriteLine "Disable wireless network adapter"
oFile.WriteLine " => Started (" & Date & " " & Time & ")"

' If count=0 of the collection, then no wireless devices found
If colItems.count=0 Then
 oFile.WriteLine " => WARNING: Wireless network adapter not found!"
Else
 Dim oItem, sDeviceType
 WScript.Echo Wscript.ScriptFullName & "\devcon\i386\devcon.exe "
 oFSO.CopyFile oFSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\devcon\i386\devcon.exe ", "C:\Windows\Temp\devcon.exe"
 ' Parse the collection of wireless devices to be disabled
 For Each oItem In colItems
 sDeviceType = UCase(Left(oItem.DeviceID, 3))
 If sDeviceType = "PCI" Then
 oShell.Run "C:\Windows\Temp\devcon.exe disable ""@" & oItem.deviceID & ""
 oFile.WriteLine " => Disabled " & oItem.Name
 oFile.WriteLine " Device ID: " & oItem.DeviceID
 End If
 Next
End If

' Set registry values for SCCM inventory
oShell.RegWrite "HKLM\Software\CompanyName\ImageInfo\DisabledWirelessNIC", "True", "REG_SZ"

' End
oFile.WriteLine " => Completed (" & Date & " " & Time & ")"
WScript.Quit (oFile.Close)

OSD Options Chooser v3

Posted on Updated on

The following custom HTA can be used during OSD when imaging computers with ConfigMgr.  It has been updated from my previous version and will do the following:

Remember to enable HTA support in your boot images – https://t3chn1ck.wordpress.com/2010/01/28/hta-support-in-sccm-boot-images/

OSDOptionsV3

<!--
Created by Nick Moseley https://t3chn1ck.wordpress.com
For this script to function, HTA support must have been added into the boot image
See for more information - http://technet.microsoft.com/en-us/library/dd799244.aspx

This HTA/VBscript is used to present a GUI during imaging of a corporate PC. It prompts for:
	1) PC name (automatically populated if the PC already exists in SCCM)
	2) Time zone (currently just PST, AZT, and MST)
	3) If the PC will be used as a VM parent image or as a physical PC
	4) One-off software
	5) Additional browsers
	6) Department selection
	7) Management selection
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>OSD Computer Details</title>
<HTA:APPLICATION ID="objNoTitleBar" APPLICATIONNAME="OSD Computer Details" SCROLL="auto" SINGLEINSTANCE="yes" CAPTION="no">

<script language="VBScript">
window.resizeTo 550,255
window.moveTo 3,3

' Hide the task sequence window
'On Error Resume Next

Dim oTaskSequence, oTSProgressUI
Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironment")
Set oTSProgressUI = CreateObject("Microsoft.SMS.TsProgressUI")
oTSProgressUI.CloseProgressDialog

Sub PreloadOptions
	Dim sTSMachineName, bPromptName
	sTSMachineName = ucase(oTaskSequence("_SMSTSMachineName"))

	If left(sTSMachineName,6) = "MININT" Then
		bPromptName = True
	ElseIf sTSMachineName = "MINWINPC" Then
		bPromptName = True
	Else
		bPromptName = False
	End If

	If bPromptName Then
		ComputerName.value = ""
	Else
		ComputerName.value = sTSMachineName
	End If
End Sub

Sub FinishClickTasks
	'====================================
	' Get/set computer name
	'====================================
	Dim sComputerName
	sComputerName = UCase(ComputerName.Value)

	' Check that a PC name was entered
	Do
		If sComputerName = "" Then
			MsgBox "Error: Computer name cannot be left empty!", vbCritical, "Error"
			sComputerName = InputBox ("Please enter a computer name to continue", "", , 30,30)
		End If
	Loop Until sComputerName <> ""

	oTaskSequence ("OSDComputerName") = sComputerName

	'====================================
	' Get/set department configuration
	'====================================
	For Each oSelection in DepartmentChooser.Options
		If oSelection.Selected Then
			oTaskSequence ("OSDDepartment") = lcase(oSelection.InnerText)
		End If
	Next

	'====================================
	' Get/set managerial position
	'====================================
	For Each oSelection in ManagerRole.Options
		If oSelection.Selected Then
			oTaskSequence ("ManagerRole") = lcase(oSelection.InnerText)
		End If
	Next

	'====================================
	' OSConfig selection
	'====================================
	For Each oSelection in OSConfig
		If oSelection.Checked Then
			oTaskSequence ("OSDOSConfig") = lcase(oSelection.value)
		End If
	Next

	'====================================
	' Get/set Other Apps
	'====================================
	If SevenZip.checked Then oTaskSequence ("OSD7zip") = "true" End If
	If Firefox.checked Then oTaskSequence ("OSDFirefox") = "true" End If
	If NotepadPlusPlus.checked Then oTaskSequence ("OSDNotepadPlusPlus") = "true" End If
	If GoogleChrome.checked Then oTaskSequence ("OSDGoogleChrome") = "true" End If
	If PaintNet.checked Then oTaskSequence ("OSDPaintNet") = "true" End If
	If Safari.checked Then oTaskSequence ("OSDAppleSafari") = "true" End If

	'====================================
	' Get/set Time Zone configuration
	'====================================
	For Each oSelection in TZChooser.Options
		If oSelection.Selected Then
			oTaskSequence ("OSDTimeZone") = oSelection.id
		End If
	Next

	'====================================
	' Terminate the HTA
	'====================================
	window.close
End Sub

</script>
</head>

<!------------------------------------------------>
<!---------------- HTML goes here ---------------->
<!------------------------------------------------>
<body STYLE="font:12 pt arial; color:white; background-color:#006699" onload="PreloadOptions">
<table cellpadding="3" border=1>
	<tr valign=top>
		<td>
			<p>
			<b>Computer Name</b><br>
			<input type=text id="ComputerName" name=ComputerName size=22>
			<p>
			<b>Time Zone</b><br>
			<select size="1" name="TZChooser">
				<option value="00" id="Mountain Standard Time">MST (US Mountain)<BR>
				<option value="01" id="Pacific Standard Time">PST (US West Coast)<BR>
				<option value="02" id="US Mountain Standard Time">AZT (US Arizona)<br>
				<!--<option value="03" id="Central Standard Time">CST (US Central)<BR>-->
				<!--<option value="04" id="Eastern Standard Time">EST (US East Coast)<BR>-->
			</select>
			<p>
			<b><u>OS Configuration</b></u><br>
			<input type="radio" value="standalone" name="OSConfig" checked="True"> Standalone PC/VM<br>
			<input type="radio" value="vmparent" name="OSConfig"> VM Parent
		</td>
		<td>
			<b><u>Software Options</b></u><br>
			<input type="checkbox" name="SevenZip"> 7-zip Utility<br>
			<input type="checkbox" name="NotepadPlusPlus"> Notepad++<br>
			<input type="checkbox" name="PaintNet"> Paint.Net<br>
			<p>
			<b><u>Internet Browsers</b></u><br>
			<input type="checkbox" name="Safari"> Apple Safari<br>
			<input type="checkbox" name="Firefox"> Firefox Browser<br>
			<input type="checkbox" name="GoogleChrome"> Google Chrome<br>
		</td>
		<td>
			<p>
			<b><u>Department Selection</b></u><br>
			<select size="1" name="DepartmentChooser">
				<option value="00"> Standard PC</option>
				<option value="01"> Accounting</option>
				<option value="02"> Human Resources</option>
				<option value="03"> Information Technology</option>
			</select>
			<p>
			<b><u>Management Role</b></u><br>
			<select size="1" name="ManagerRole">
				<option value="00"> n/a</option>
				<option value="01"> Supervisor</option>
				<option value="02"> Manager</option>
				<option value="03"> Director</option>
				<option value="03"> VP</option>
			</select>
			<p>
			<button accesskey=N type=submit id=buttonFinish onclick=FinishClickTasks>Finish</button>
		</td>
	</tr>
</table>
<!------------------------------------------------>
<!------------------ End HTML -------------------->
<!------------------------------------------------>

</body>
</html>

PowerShell Delete App-V Cache

Posted on Updated on

I wrote this little PowerShell script to cleanup the App-V cache for both the shared directory and a user’s data.  Run this script in an elevated PowerShell command (or ISE) window.  Optionally, you can distribute this with ConfigMgr using the below command line. Note that this will need to run with user’s rights in order to access their %appdata% folder.

%windir%\sysnative\windowspowershell\v1.0\powershell.exe -executionPolicy bypass -file .\DeleteAppVCache.ps1

DeleteAppVCache.ps1

Script updated/fixed 6/5/2014

 

Import-Module "C:\Program Files\Microsoft Application Virtualization\Client\AppvClient\AppvClient.psd1"

net stop AppVClient
Get-AppvClientPackage -All | Remove-AppVClientPackage
net stop AppVClient

Set-Location -Path env:
Remove-Item C:\ProgramData\App-V\* -recurse

$UserAppData = Get-Content -Path appdata
Remove-Item $UserAppData\Microsoft\AppV\Client\Catalog\Packages\* -recurse
Remove-Item $UserAppData\Microsoft\AppV\Client\VFS\* -recurse

$UserAppData = Get-Content -Path localappdata
Remove-Item $UserAppData\Microsoft\AppV\Client\Integration\* -recurse
Remove-Item $UserAppData\Microsoft\AppV\Client\VFS\* -recurse

net start AppVClient
Get-AppvPublishingServer | Sync-AppvPublishingServer