The Collection

A collection of useful information.

Filtering by Category: Other

SCCM 2012: Get Locked Apps/Packages

$query = "SELECT		SEDO_LockState.LockStateID,
			SEDO_LockState.AssignedUser,
			SEDO_LockState.AssignmentTime,
			SEDO_LockState.AssignedUser,
			SEDO_LockState.AssignedMachine,
			v_SmsPackage.Name,
			fn_ListApplicationCIs.DisplayName,
			fn_ListApplicationCIs.Manufacturer

FROM		SEDO_LockState INNER JOIN
				SEDO_LockableObjects ON SEDO_LockState.LockID = SEDO_LockableObjects.LockID INNER JOIN
					SEDO_LockableObjectComponents ON (SEDO_LockableObjects.ObjectID = SEDO_LockableObjectComponents.ObjectID) LEFT OUTER JOIN
						v_SmsPackage ON SEDO_LockableObjectComponents.ComponentID = v_SmsPackage.SEDOComponentID LEFT OUTER JOIN
						CI_ConfigurationItems ON SEDO_LockableObjectComponents.ComponentID = CI_ConfigurationItems.SEDOComponentID LEFT OUTER JOIN
						fn_ListApplicationCIs(1033) ON CI_ConfigurationItems.CI_UniqueID = fn_ListApplicationCIs.CI_UniqueID
WHERE		(SEDO_LockState.LockStateID <> 0)"

$server = ""
$db = ""
$constring = "Server=$server;Database=$db;Integrated Security=True"

$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $constring
$connection.Open()

$command = $connection.CreateCommand()
$command.CommandText = $query

$result = $command.ExecuteReader()

$table = New-Object System.Data.DataTable
$table.Load($result)

$connection.Close()

$table.Rows | Format-Table

Connect Network Printer via WMI

Very simple example, this can be run from any powershell ci:

([wmiclass]"Win32_Printer").AddPrinterConnection("\\\")

ex: <server> = printsrv01, <port> = R1414

The specific path should be fairly obvious if you browse to the printer server hosting the printer in question, it should show up as a device and you can just concatenate that onto the end and pipe it to WMI, simple.

The Prime Rule of Software Deployment.

There is but one rule that you need to remember if your job is deploying software. It is law, it is god, and you had best obey it if you want to simply your life.

There is no such thing as 100%.

You can apply it however you want, but it should be the first thing on your mind.

There is no such thing as a package/sequence that will run on every machine.

There is no such thing as a solution that will work 100% of the time.

There is no such thing as 100% reliability.

All good things to strive for, don't get me wrong. The point is not to rely on anything to be the "critical point". The one thing that makes everything else work. Reliability comes from simplicity. The more moving parts, the more likely it will be to fail, the more oddities will crop up, the more downtime you will have, the more work you will have to do.

It's easy to shoot for everything and the kitchen sink to provide awesome features to the client, or come up with an elaborate solution to a problem.

But bear this in mind. Duct tape is synonymous with fixing things for a reason. It's simple, it does a job, and very little can go wrong with it.

Find ways to make elegant and simple solutions work for complex problems and your life (and paycheck) will improve as a result.

Just some free advice inspired by a few recent questions.

How-To: Windows 7 Thumb Drive

Elevate a command prompt and do the following

 

  • :> diskpart
  • :> list disk
  • Find the disk ID of the thumb drive (Disk1, Disk2 etc.), this will be X.
  • :> select X
  • clean
  • create partition primary
  • format fs=ntfs quick
  • assign
  • active
  • exit

Now take the Win7 install media and extract it locally, there will be a "boot" folder under wherever you extracted it, go back to your elevated command prompt and type: <pathtobootfolder>\bootsect.exe /nt60 $:

$: is the drive letter assigned to your thumbdrive during the preparation stage.

You should now have a bootable, installable, USB thumb drive.

 

RSAT: Enable via Powershell

You can use wusa <path to .msu> /quiet to install the update, then run this powershell script to enable all the features for RSAT.

 

&$env:systemroot\SysNative\dism.exe /Online /Enable-Feature:IIS-WebServerRole
&$env:systemroot\SysNative\dism.exe /Online /Enable-Feature:IIS-WebServerManagementTools
&$env:systemroot\SysNative\dism.exe /Online /Enable-Feature:IIS-IIS6ManagementCompatibility
&$env:systemroot\SysNative\dism.exe /Online /Enable-Feature:IIS-Metabase
&$env:systemroot\SysNative\dism.exe /Online /Enable-Feature:IIS-LegacySnapIn
&$env:systemroot\SysNative\dism.exe /online /get-features | Select-String -Pattern remote* | %{$Exec = "dism.exe /online /enable-feature /featurename:RemoteServerAdministrationTools /featurename:" + ($_).ToString().Replace('Feature Name : ',''); Invoke-expression $Exec}
&$env:systemroot\SysNative\dism.exe /Online /Enable-Feature:RemoteServerAdministrationTools-Roles-AD-DS-AdministrativeCenter

 

via Xenophane

Update: If you don't want the SMTP Server Tools installed you can ditch the dism lines that turn on all the IIS components and just run the /get-features line and the AdminCenter line after it. The reason for running Admin Center again is because it shows up in the list before its pre-req so it fails to enable the first time around, so you just enable it again and viola...

Update 2: I modified the script and had the WiseScript call it because SCCM kinda blows. I had to modify the script because calling it with WiseScript tripped the issue with DISM reverting to the x86 version, which errors out, so now it's pointing to the SysNative version (another brilliant idea from microsoft, I guess calling it dism64 or defaulting to x64 and not x86 or about fifty other options made too much sense and therefor had to go).

Service Manager 7.11: Command Line Options

Don't ask me why I'm posting this here, Service Manager is one of the worst written things I've ever used, and I use App-V. No surprise it's written in Java. The developers need to be drawn and quartered.

-silent

-options-record <answer file>

-options <answer file>

For a silent default install just use -silent, for one that uses the answer file, just do -option AND -silent.

Ugh.