Skip to content

Instantly share code, notes, and snippets.

Avatar

Kaido Järvemets Kaidja

View GitHub Profile
View ObjectsInFolderSCCM2
$ObjectPath = "/Dell/Sub1"
$ApplicationsInFolder = Get-WmiObject -Namespace "ROOT\SMS\Site_PS1" `
-Query "select * from SMS_ApplicationLatest where ObjectPath = '$ObjectPath'"
$ApplicationsInFolder
View ConvertTo-CMIResultObject
$SCCMCMPSHObject = ConvertTo-CMIResultObject -InputObject $ApplicationsInFolder
Set-CMApplication -InputObject $SCCMCMPSHObject -NewName "IT - Dell Command Monitor 2"
View ModifySCCMObject
Set-CMApplication -InputObject $ApplicationsInFolder -NewName "IT - Dell Command Monitor 2"
View ObjectsInFolderSCCM
$FolderID = 16777224 # ContainerNodeID property value
$SiteCode = "PS1"
$Query = "select * from SMS_ApplicationLatest where ModelName is
in(select InstanceKey from SMS_ObjectContainerItem where ObjectType='6000' and ContainerNodeID='$FolderID')"
$ApplicationsInFolder = Get-WmiObject -Namespace "ROOT\SMS\Site_$SiteCode" -Query $Query
$ApplicationsInFolder
View SCCMContainerNodeID
Get-ChildItem PS1:\Application | Select-Object -Property Name,ContainerNodeID,ObjectType
View Import Maintenance Windows before import
Import-CMMaintenanceWindows.ps1 -MWsInputFile E:\Scripts\MW\Maintenance_Solution.csv -Delimiter ',' -Production
View Preview Maintenance Windows before import
Import-CMMaintenanceWindows.ps1 -MWsInputFile E:\Scripts\MW\Maintenance_Solution.csv -Delimiter ',' -Preview
View AD computer LastLogonDate
#AD Computer account last logon date
Get-ADComputer -Identity KLASSB315-2 -Properties LastLogonDate
#AD Computer account last logon date in days
$ADComputerInfo = Get-ADComputer -Identity PC1 -Properties LastLogonDate
$TimeSpan = New-TimeSpan -Start $ADComputerInfo.LastLogonDate -End (Get-Date)
$TimeSpan.Days
View Getting data from ConfigMgr - Invoke-CMQuery
Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1")
$CMSite = Get-PSProvider -PSProvider CMSITE
Set-Location -Path "$($CMSite.Drives.Name):\"
Invoke-CMQuery -Name 'All Non-Client Systems'
View Check if device exists in Configuration Manager
#Check if device exists in Configuration Manager
Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1")
$CMSite = Get-PSProvider -PSProvider CMSITE
Set-Location -Path "$($CMSite.Drives.Name):\"
#Query against Configuration Manager
$ADComputerInfo = Get-ADComputer -Identity PC1
Get-CMDevice -Name $ADComputerInfo.Name
You can’t perform that action at this time.