I have an interesting situation with SCCM cmdlets. I am hoping somebody can help me with this situation.
I am trying to get the ISactive property result out of Get-CMDevice.
I have created a custom script and can get a object out of sccm.
I can even produce a variable.
function Get-SCCMDeviceinfo { Param ( [Parameter(Mandatory = $True)] [String]$Computername ) Process { $CMModule = import-module "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1" $CMSiteCode = 'PRM' $CMSiteCode = $CMSiteCode + ":" Import-Module "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1" Set-Location $CMSiteCode Get-CMDevice -name $Computername Set-Location c:\ } }
In the CLI it works. I get the result that I want. I use get-member I get output to say what properties are there.
Yet when I run the custom cmdlet in a script or even Get-CMDevice (doing the manual steps stepping through to the CMSite) it comes up with a blank value,
I have the hash table in question below in which I am using the output. Everything works apart from that single entry on ‘SCCMAgentActive’:
The other hash table is actually being pulled from a custom xml of a system report being generated by another script.
$Systeminformation = [Ordered]@{ Computername = $($SavedSystemReport.name) NumberofCores = $($SavedSystemReport.numCPU) Operatingsystem = $($SavedSystemReport.OperatingSystem) RegionalSetting = $($SavedSystemReport.RegionalSetting) ActiveDirectoryDomainName = $($SavedSystemReport.Domain) ActiveDirectoryOrganizationalUnit = $($SavedSystemReport.OrganizationalUnit) CDROMDriveLetter = $($SavedSystemReport.OpticalDrive) | select -ExpandProperty driveletter LocalComputerDescription = $($SavedSystemReport.Description) | Select -ExpandProperty Description ActiveDirectoryDescription = $(Get-ADComputer -identity $($SavedSystemReport.name) -Properties description | select -expand description) SCCMAgentActive = $(Get-SCCMDeviceinfo -Computername $Computer| select -expand IsActive) ServicePack = $($SavedSystemReport.ServicePack) TimeServiceRunning = $($SavedSystemReport.TimeserviceRunning) SystemManagedPageFile = $($SavedSystemReport.AutomaticManagedPageFile) Ram = "{0:N02}" -f $($SavedSystemReport.RAM/1GB) }
Any help appreciated.