├── Modules
├── placeholder.txt
├── CMOperations
│ ├── LICENSE
│ └── CMOperations.psd1
└── Scripts
│ ├── Set-WifiProfile.PS1
│ └── Modify-BootStrapInfo.PS1
├── Reporting
├── SCConfigMgr-PatchingDashboardV2.5.pbit
├── SCConfigMGR-Patch-ComplianceV1.0.0.8.pbit
└── Export-CMReports.ps1
├── README.md
├── Operating System Deployment
├── Windows Servicing
│ ├── Invoke-CMResetWinRE.ps1
│ ├── Invoke-CMDetectCurrentOSVersion.ps1
│ ├── Invoke-CMDetectMBRPartitions.ps1
│ ├── Invoke-CMDetectBitLockerEncryption.ps1
│ └── Invoke-CMDetectFirmwareMode.ps1
├── Invoke-TSDumpVariables.ps1
├── Invoke-DellCCTKCheck.ps1
├── Enable-UbuntuForWindows.ps1
├── Set-WindowsDefenderSetting.ps1
├── BIOS
│ └── Invoke-MicrosoftBIOSUpdate.ps1
├── Enable-CredentialGuard.ps1
├── Invoke-ITMaintenanceMessage.ps1
├── TPM
│ └── Invoke-ManageTPMOwnership.ps1
├── Build and Capture
│ └── Set-CMWindowsStoreUpdates.ps1
└── Invoke-TPMOwnerPassword.ps1
├── Application
├── Get-MSIFileInformation.ps1
├── ConvertFrom-CMApplicationCIUniqueID.ps1
├── Add-CMApplicationRequirementRule.ps1
├── Get-CMApplicationsRequirementPrimaryDevice.ps1
├── Start-ApplicationDistribution.ps1
├── Get-CMApplicationWithDependency.ps1
└── Set-CMApplicationPostInstallBehavior.ps1
├── Console Extension
├── CreateSoftwareUpdateGroup
│ └── CreateSoftwareUpdateGroup.xml
├── GetMaintenanceWindows
│ └── MW.xml
└── DellWarranty
│ └── 3.0
│ ├── DellWarranty.xml
│ └── MainWindow.xaml
├── Device Collection
├── Rename-CMCollections.ps1
└── Remove-DeviceFromCollection.ps1
├── Site Administration
├── Set-CMDiscoveryMethodADGroupScope.ps1
├── Set-CMMaxMIFSize.ps1
├── Get-CMIPRangeBoundary.ps1
├── Set-CMAdditionalUpdateLanguagesForOffice365.ps1
└── Set-CMCloudManagementGatewayState.ps1
├── Client
├── Clean-CMClientCache.ps1
├── Get-CMDeviceModels.ps1
├── Get-CMDeviceIPAddresses.ps1
└── Import-CMDevice.ps1
├── Compliance Settings
└── Set-OPPUpdateChannel.ps1
├── Content
├── Invoke-CMFailedContentRefresh.ps1
└── Invoke-CMDeploymentTypeContentUpdate.ps1
├── Software Updates
├── ConvertTo-CMSoftwareUpdate.ps1
├── Invoke-ADRDeploymentPackage.ps1
├── Add-CMWSUSScanRetryErrorCodes.ps1
└── New-CMDeploymentPackage.ps1
├── Package
└── Get-CMDisabledPrograms.ps1
├── Migration
├── Import-CMStatusMessageQuery.ps1
└── Import-CMQuery.ps1
├── Software Distribution
└── Install-MBAMClient.ps1
└── Maintenance Windows
├── Get-CMDeviceMaintenanceWindow.ps1
└── Remove-YearlyMWindow.PS1
/Modules/placeholder.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Reporting/SCConfigMgr-PatchingDashboardV2.5.pbit:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MSEndpointMgr/ConfigMgr/HEAD/Reporting/SCConfigMgr-PatchingDashboardV2.5.pbit
--------------------------------------------------------------------------------
/Reporting/SCConfigMGR-Patch-ComplianceV1.0.0.8.pbit:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MSEndpointMgr/ConfigMgr/HEAD/Reporting/SCConfigMGR-Patch-ComplianceV1.0.0.8.pbit
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ConfigMgr
2 | System Center Configuration Manager scripts
3 |
4 | Scripts are provided as is with no liability and should be tested in a controlled environment.
5 |
--------------------------------------------------------------------------------
/Operating System Deployment/Windows Servicing/Invoke-CMResetWinRE.ps1:
--------------------------------------------------------------------------------
1 | # Disable WinRE
2 | try {
3 | Start-Process -FilePath "reagentc.exe" -ArgumentList "/Disable" -Wait -ErrorAction Stop
4 | }
5 | catch [System.Exception] {
6 | Write-Warning -Message "An error occured while disabling WinRE. Error message: $($_.Exception.Message)" ; exit 1
7 | }
8 |
9 | # Enable WinRE
10 | try {
11 | Start-Process -FilePath "reagentc.exe" -ArgumentList "/Enable" -Wait -ErrorAction Stop
12 | }
13 | catch [System.Exception] {
14 | Write-Warning -Message "An error occured while enabling WinRE. Error message: $($_.Exception.Message)" ; exit 1
15 | }
--------------------------------------------------------------------------------
/Operating System Deployment/Windows Servicing/Invoke-CMDetectCurrentOSVersion.ps1:
--------------------------------------------------------------------------------
1 | # Load Microsoft.SMS.TSEnvironment COM object
2 | try {
3 | $TSEnvironment = New-Object -ComObject Microsoft.SMS.TSEnvironment -ErrorAction Stop
4 | }
5 | catch [System.Exception] {
6 | Write-Warning -Message "Unable to construct Microsoft.SMS.TSEnvironment object" ; exit 1
7 | }
8 |
9 | # Determine current OS version
10 | $BuildNumber = Get-WmiObject -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber
11 |
12 | # Set task sequence variable
13 | try {
14 | $TSEnvironment.Value("OSDCurrentOSVersion") = "$($BuildNumber)"
15 | }
16 | catch [System.Exception] {
17 | Write-Warning -Message "An error occured while setting task sequence variable. Error message: $($_.Exception.Message)" ; exit 1
18 | }
--------------------------------------------------------------------------------
/Application/Get-MSIFileInformation.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [parameter(Mandatory=$true)]
3 | [IO.FileInfo]$Path,
4 | [parameter(Mandatory=$true)]
5 | [ValidateSet("ProductCode","ProductVersion","ProductName")]
6 | [string]$Property
7 | )
8 | try {
9 | $WindowsInstaller = New-Object -ComObject WindowsInstaller.Installer
10 | $MSIDatabase = $WindowsInstaller.GetType().InvokeMember("OpenDatabase","InvokeMethod",$Null,$WindowsInstaller,@($Path.FullName,0))
11 | $Query = "SELECT Value FROM Property WHERE Property = '$($Property)'"
12 | $View = $MSIDatabase.GetType().InvokeMember("OpenView","InvokeMethod",$null,$MSIDatabase,($Query))
13 | $View.GetType().InvokeMember("Execute", "InvokeMethod", $null, $View, $null)
14 | $Record = $View.GetType().InvokeMember("Fetch","InvokeMethod",$null,$View,$null)
15 | $Value = $Record.GetType().InvokeMember("StringData","GetProperty",$null,$Record,1)
16 | return $Value
17 | }
18 | catch {
19 | Write-Output $_.Exception.Message
20 | }
--------------------------------------------------------------------------------
/Operating System Deployment/Windows Servicing/Invoke-CMDetectMBRPartitions.ps1:
--------------------------------------------------------------------------------
1 | # Load Microsoft.SMS.TSEnvironment COM object
2 | try {
3 | $TSEnvironment = New-Object -ComObject Microsoft.SMS.TSEnvironment -ErrorAction Stop
4 | }
5 | catch [System.Exception] {
6 | Write-Warning -Message "Unable to construct Microsoft.SMS.TSEnvironment object" ; exit 1
7 | }
8 |
9 | # Detect amount of partitions for system drive
10 | $DriveLetter = $env:SystemDrive.Substring(0,1)
11 | $SystemDrivePartitionCount = (Get-Partition -DriveLetter $DriveLetter | Measure-Object).Count
12 |
13 | # Set task sequence variable
14 | try {
15 | if ($SystemDrivePartitionCount -le 3) {
16 | $TSEnvironment.Value("OSDConvertToGPT") = "True"
17 | }
18 | else {
19 | $TSEnvironment.Value("OSDConvertToGPT") = "False"
20 | }
21 | }
22 | catch [System.Exception] {
23 | Write-Warning -Message "An error occured while setting task sequence variable. Error message: $($_.Exception.Message)" ; exit 1
24 | }
--------------------------------------------------------------------------------
/Operating System Deployment/Windows Servicing/Invoke-CMDetectBitLockerEncryption.ps1:
--------------------------------------------------------------------------------
1 | # Load Microsoft.SMS.TSEnvironment COM object
2 | try {
3 | $TSEnvironment = New-Object -ComObject Microsoft.SMS.TSEnvironment -ErrorAction Stop
4 | }
5 | catch [System.Exception] {
6 | Write-Warning -Message "Unable to construct Microsoft.SMS.TSEnvironment object" ; exit 1
7 | }
8 |
9 | # Detect encrypted drives
10 | $OSDriveEncrypted = $false
11 | $EncryptedVolumes = Get-WmiObject -Namespace "root\cimv2\Security\MicrosoftVolumeEncryption" -Class "Win32_EncryptableVolume"
12 | foreach ($Volume in $EncryptedVolumes) {
13 | if ($Volume.DriveLetter -like $env:SystemDrive) {
14 | if ($Volume.EncryptionMethod -ge 1) {
15 | $OSDriveEncrypted = $true
16 | }
17 | }
18 | }
19 |
20 | # Set task sequence variable
21 | try {
22 | $TSEnvironment.Value("OSDBitLockerEncrypted") = "$($OSDriveEncrypted)"
23 | }
24 | catch [System.Exception] {
25 | Write-Warning -Message "An error occured while setting task sequence variable. Error message: $($_.Exception.Message)" ; exit 1
26 | }
--------------------------------------------------------------------------------
/Console Extension/CreateSoftwareUpdateGroup/CreateSoftwareUpdateGroup.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | DefaultHomeTab
4 | ContextMenu
5 |
6 |
7 | AdminUI.CollectionProperty.dll
8 | Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources
9 |
10 |
11 |
12 | AdminUI.UIResources.dll
13 | Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
14 |
15 | SUM_Update
16 |
17 |
18 | "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
19 | -WindowStyle Hidden -ExecutionPolicy ByPass -File #PATH# -SiteServer #SERVER#
20 |
21 |
--------------------------------------------------------------------------------
/Modules/CMOperations/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 JordanTheITGuy
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/Device Collection/Rename-CMCollections.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding()]
2 | param(
3 | [parameter(Mandatory=$true)]
4 | [string]$SiteServer,
5 | [parameter(Mandatory=$true)]
6 | [string]$SiteCode,
7 | [parameter(Mandatory=$true)]
8 | [int]$CollectionType,
9 | [parameter(Mandatory=$true)]
10 | [string]$SearchFor,
11 | [parameter(Mandatory=$true)]
12 | [string]$ReplaceWith,
13 | [parameter(Mandatory=$false)]
14 | [switch]$WhatIf
15 | )
16 | Process {
17 | $Collections = Get-WmiObject -Class SMS_Collection -Namespace "root\SMS\site_$($SiteCode)" -ComputerName "$($SiteServer)" | Where-Object { ($_.CollectionType -eq $CollectionType) -and ($_.Name -like "*$($SearchFor)*") }
18 | $Collections | ForEach-Object {
19 | if ($WhatIf -eq $true) {
20 | Write-Output "Collection to rename: $($_.Name)"
21 | }
22 | elseif ($WhatIf -ne $true) {
23 | Write-Output "Current collection name: $($_.Name)"
24 | Write-Output "New collection name: $($_.Name -replace "$($SearchFor)","$($ReplaceWith)")`n"
25 | $_.Name = $_.Name -replace "$($SearchFor)","$($ReplaceWith)"
26 | $_.Put() | Out-Null
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/Console Extension/GetMaintenanceWindows/MW.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ContextMenu
4 |
5 |
6 | AdminUI.CollectionProperty.dll
7 | Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources
8 |
9 |
10 |
11 | AdminUI.UIResources.dll
12 | Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
13 |
14 | Information
15 |
16 |
17 | "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
18 | -windowstyle hidden -executionpolicy bypass -file "C:\Scripts\Get-MaintenanceWindows.ps1" -SiteServer "##SUB:__Server##" -SiteCode "##SUB:SiteCode##" -ResourceID "##SUB:ResourceID##"
19 |
20 |
--------------------------------------------------------------------------------
/Console Extension/DellWarranty/3.0/DellWarranty.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | DefaultHomeTab
4 | ContextMenu
5 |
6 |
7 | AdminUI.CollectionProperty.dll
8 | Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources
9 |
10 |
11 |
12 | AdminUI.UIResources.dll
13 | Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
14 |
15 | Information
16 |
17 |
18 | "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
19 | -sta -WindowStyle Hidden -ExecutionPolicy ByPass -File "C:\Scripts\DellWarranty\Invoke-DellWarrantyTool_3.0.ps1" -SiteServer ##SUB:__Server## -APIKey YOURAPIKEY -DeviceName ##SUB:Name## -ResourceID ##SUB:ResourceID##
20 |
21 |
--------------------------------------------------------------------------------
/Site Administration/Set-CMDiscoveryMethodADGroupScope.ps1:
--------------------------------------------------------------------------------
1 | # Import Configuration Manager module
2 | Import-Module -Name ConfigurationManager
3 |
4 | # Set location to the ConfigMgr PSDrive
5 | Set-Location -Path P01:
6 |
7 | # Define variables
8 | $SearchFilter = "Groups"
9 | $SearchBase = "OU=Contoso,DC=contoso,DC=com"
10 |
11 | # Get distinguished names for eligible OU's
12 | $OUDistinguishedNames = Get-ADOrganizationalUnit -Filter "Name -like '$($SearchFilter)'" -SearchBase $SearchBase | Select-Object -ExpandProperty DistinguishedName
13 |
14 | # Construct array list
15 | $ADGroupDiscoveryList = New-Object -TypeName System.Collections.ArrayList
16 |
17 | # Process each discovered AD object
18 | foreach ($OUDistinguishedName in $OUDistinguishedNames) {
19 | # Determine parent OU name
20 | $OUParent = (([ADSI]"LDAP://$($OUDistinguishedName)").Parent).SubString(7)
21 | $OUParentName = Get-ADOrganizationalUnit -Identity $OUParent | Select-Object -ExpandProperty Name
22 |
23 | # Create new ADGroupDiscoveryScope object and add it to the array list
24 | $ADGroupDiscoveryScope = New-CMADGroupDiscoveryScope -Name $OUParentName -LdapLocation "LDAP://$($OUDistinguishedName)" -RecursiveSearch $true
25 | $ADGroupDiscoveryList.Add($ADGroupDiscoveryScope) | Out-Null
26 |
27 | }
28 |
29 | # Set the Discovery Method scope
30 | Set-CMDiscoveryMethod -ActiveDirectoryGroupDiscovery -AddGroupDiscoveryScope $ADGroupDiscoveryList
--------------------------------------------------------------------------------
/Operating System Deployment/Windows Servicing/Invoke-CMDetectFirmwareMode.ps1:
--------------------------------------------------------------------------------
1 | # Load Microsoft.SMS.TSEnvironment COM object
2 | try {
3 | $TSEnvironment = New-Object -ComObject Microsoft.SMS.TSEnvironment -ErrorAction Stop
4 | }
5 | catch [System.Exception] {
6 | Write-Warning -Message "Unable to construct Microsoft.SMS.TSEnvironment object" ; exit 1
7 | }
8 |
9 | # Load firmware type from kernel32.dll
10 | Add-Type -Language CSharp -TypeDefinition @"
11 |
12 | using System;
13 | using System.Runtime.InteropServices;
14 |
15 | public class FirmwareType
16 | {
17 | [DllImport("kernel32.dll")]
18 | static extern bool GetFirmwareType(ref uint FirmwareType);
19 |
20 | public static uint GetFirmwareType()
21 | {
22 | uint firmwaretype = 0;
23 | if (GetFirmwareType(ref firmwaretype))
24 | return firmwaretype;
25 | else
26 | return 0;
27 | }
28 | }
29 | "@
30 |
31 | # Determine firmware type
32 | switch ([FirmwareType]::GetFirmwareType()) {
33 | 1 { $FirmwareType = "BIOS" }
34 | 2 { $FirmwareType = "UEFI" }
35 | 0 { $FirmwareType = "Unknown" }
36 | }
37 |
38 | # Set task sequence variable
39 | try {
40 | $TSEnvironment.Value("OSDFirmwareType") = "$($FirmwareType)"
41 | }
42 | catch [System.Exception] {
43 | Write-Warning -Message "An error occured while setting task sequence variable. Error message: $($_.Exception.Message)" ; exit 1
44 | }
--------------------------------------------------------------------------------
/Site Administration/Set-CMMaxMIFSize.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | This function can be run against a server to set the 'Max MIF Size' registry value.
4 | .DESCRIPTION
5 | This function can be run against a server to set the 'Max MIF Size' registry value.
6 | .PARAMETER ComputerName
7 | The NetBIOS name of the computer to run the script against.
8 | .PARAMETER Size
9 | Integer value of the maximum size for MIF size that the system will handle. Specified in hex, e.g. 3200000 = 50MB.
10 | .NOTES
11 | Name: Set-MaxMIFSize
12 | Author: Nickolaj Andersen
13 | DateCreated: 2014-01-07
14 |
15 | .LINK
16 | http://www.scconfigmgr.com
17 | .EXAMPLE
18 | Set-CMMaxMIFSize -ComputerName 'SRV001' -Size 3200000
19 |
20 | Description
21 | -----------
22 | This command will set the 'Max MIF Size' DWORD value in 'HKLM\SOFTWARE\Microsoft\SMS\Components\SMS_INVENTORY_DATA_LOADER'.
23 |
24 | #>
25 | [CmdletBinding()]
26 | param(
27 | [ValidateScript({Test-Connection -ComputerName $_ -Count 1})]
28 | [ValidateNotNull()]
29 | [parameter(Mandatory=$true,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)]
30 | $ComputerName,
31 | [ValidateNotNull()]
32 | [parameter(Mandatory=$true)]
33 | [int]$Size
34 | )
35 | Process {
36 | try {
37 | Invoke-Command -ComputerName $ComputerName -ScriptBlock {
38 | param(
39 | $Size,
40 | $ComputerName
41 | )
42 | $Key = "SOFTWARE\Microsoft\SMS\Components\SMS_INVENTORY_DATA_LOADER"
43 | $BaseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $ComputerName)
44 | $SubKey = $BaseKey.OpenSubkey($Key,$true)
45 | $SubKey.SetValue('Max MIF Size',$Size,[Microsoft.Win32.RegistryValueKind]::DWORD)
46 | } -ArgumentList ($Size,$ComputerName)
47 | }
48 | catch {
49 | Write-Output $_.Exception.Message
50 | }
51 | }
--------------------------------------------------------------------------------
/Console Extension/DellWarranty/3.0/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Client/Clean-CMClientCache.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Clean the ConfigMgr client cache for items not used within the set amount of retention days.
4 |
5 | .DESCRIPTION
6 | Clean the ConfigMgr client cache for items not used within the set amount of retention days.
7 |
8 | .PARAMETER RetentionDays
9 | Purge client cache items not refreshed within the set value.
10 |
11 | .EXAMPLE
12 | # Purge items in the ConfigMgr client cache that have not been refreshed within the last 7 days:
13 | .\Clean-CMClientCache.ps1 -RetentionDays 7
14 |
15 | .NOTES
16 | FileName: Clean-CMClientCache.ps1
17 | Author: Nickolaj Andersen
18 | Contact: @NickolajA
19 | Created: 2019-02-15
20 | Updated: 2019-02-15
21 |
22 | Version history:
23 | 1.0.0 - (2019-02-15) Script created
24 | #>
25 | [CmdletBinding(SupportsShouldProcess=$true)]
26 | param(
27 | [parameter(Mandatory=$true, HelpMessage="Purge client cache items not refreshed within the set value.")]
28 | [ValidateNotNullOrEmpty()]
29 | [string]$RetentionDays
30 | )
31 | Process {
32 | # Construct a new UIResourceMgr object
33 | $CCMClient = New-Object -ComObject UIResource.UIResourceMgr
34 | if ($CCMClient -ne $null) {
35 | if (($CCMClient.GetType()).Name -match "_ComObject") {
36 | # Get client cache directory location
37 | $CCMCacheDir = ($CCMClient.GetCacheInfo().Location)
38 |
39 | # List all applications due in the future or currently running
40 | $PendingApps = $CCMClient.GetAvailableApplications() | Where-Object { (($_.StartTime -gt (Get-Date)) -or ($_.IsCurrentlyRunning -eq "1")) }
41 |
42 | # Create list of applications to purge from cache
43 | $PurgeApps = $CCMClient.GetCacheInfo().GetCacheElements() | Where-Object { ($_.ContentID -notin $PendingApps.PackageID) -and $((Test-Path -Path $_.Location) -eq $true) -and ($_.LastReferenceTime -lt (Get-Date).AddDays(-$RetentionDays)) }
44 |
45 | # Purge apps no longer required
46 | foreach ($App in $PurgeApps)
47 | {
48 | $CCMClient.GetCacheInfo().DeleteCacheElement($App.CacheElementID)
49 | }
50 |
51 | # Clean Up Misc Directories
52 | $ActiveDirs = $CCMClient.GetCacheInfo().GetCacheElements() | ForEach-Object { Write-Output $_.Location }
53 | Get-ChildItem -Path $CCMCacheDir | Where-Object { (($_.PsIsContainer -eq $true) -and ($_.FullName -notin $ActiveDirs)) } | Remove-Item -Recurse -Force -Verbose
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/Client/Get-CMDeviceModels.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Get all device models present in ConfigMgr
4 |
5 | .DESCRIPTION
6 | This script will get all device models present in ConfigMgr. It requires Hardware Inventory to be enabled and that the devices have reported a full hardware inventory report at least once.
7 |
8 | .PARAMETER SiteServer
9 | Site server name with SMS Provider installed.
10 |
11 | .EXAMPLE
12 | # Get all device models on a Primary Site server called 'CM01':
13 | .\Get-CMDeviceModels.ps1 -SiteServer CM01
14 |
15 | .NOTES
16 | FileName: Get-CMDeviceModels.ps1
17 | Author: Nickolaj Andersen
18 | Contact: @NickolajA
19 | Created: 2015-04-10
20 | Updated: 2019-03-12
21 |
22 | Version history:
23 | 1.0.0 - (2015-04-10) Script created
24 | 1.0.1 - (2019-03-12) Added manufacturer as a column in the output
25 | #>
26 | [CmdletBinding(SupportsShouldProcess=$true)]
27 | param(
28 | [parameter(Mandatory=$true, HelpMessage="Site server where the SMS Provider is installed")]
29 | [ValidateNotNullOrEmpty()]
30 | [ValidateScript({Test-Connection -ComputerName $_ -Count 1 -Quiet})]
31 | [string]$SiteServer
32 | )
33 | Begin {
34 | # Determine SiteCode from WMI
35 | try {
36 | Write-Verbose "Determining SiteCode for Site Server: '$($SiteServer)'"
37 | $SiteCodeObjects = Get-WmiObject -Namespace "root\SMS" -Class SMS_ProviderLocation -ComputerName $SiteServer -ErrorAction Stop
38 | foreach ($SiteCodeObject in $SiteCodeObjects) {
39 | if ($SiteCodeObject.ProviderForLocalSite -eq $true) {
40 | $SiteCode = $SiteCodeObject.SiteCode
41 | Write-Debug "SiteCode: $($SiteCode)"
42 | }
43 | }
44 | }
45 | catch [Exception] {
46 | Throw "Unable to determine SiteCode"
47 | }
48 | }
49 | Process {
50 | # ArrayList to store the models in
51 | $ModelsArrayList = New-Object -TypeName System.Collections.ArrayList
52 |
53 | # Enumerate through all models
54 | $ComputerSystems = Get-WmiObject -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_G_System_COMPUTER_SYSTEM -ComputerName $SiteServer | Select-Object -Property Model, Manufacturer
55 |
56 | # Add model to ArrayList if not present
57 | if ($ComputerSystems -ne $null) {
58 | foreach ($ComputerSystem in $ComputerSystems) {
59 | if ($ComputerSystem.Model -notin $ModelsArrayList.Model) {
60 | $PSObject = [PSCustomObject]@{
61 | Model = $ComputerSystem.Model
62 | Manufacturer = $ComputerSystem.Manufacturer
63 | }
64 | $ModelsArrayList.Add($PSObject) | Out-Null
65 | }
66 | }
67 | }
68 | Write-Output $ModelsArrayList
69 | }
--------------------------------------------------------------------------------
/Compliance Settings/Set-OPPUpdateChannel.ps1:
--------------------------------------------------------------------------------
1 | # Define the name of the update channel
2 | $UpdateChannelName = "Broad" # Valid options are: Monthly, Targeted, Broad and Insiders
3 |
4 | switch ($UpdateChannelName) {
5 | "Monthly" {
6 | $UpdateChannel = "http://officecdn.microsoft.com/pr/492350f6-3a01-4f97-b9c0-c7c6ddf67d60"
7 | }
8 | "Targeted" {
9 | $UpdateChannel = "http://officecdn.microsoft.com/pr/b8f9b850-328d-4355-9145-c59439a0c4cf"
10 | }
11 | "Broad" {
12 | $UpdateChannel = "http://officecdn.microsoft.com/pr/7ffbc6bf-bc32-4f92-8982-f9dd17fd3114"
13 | }
14 | "Insiders" {
15 | $UpdateChannel = "http://officecdn.microsoft.com/pr/64256afe-f5d9-4f86-8936-8840a6a4f5be"
16 | }
17 | }
18 |
19 | # Change update channel if existing does not match desired update channel
20 | Write-Output -InputObject "Chosen update channel '$($UpdateChannelName)' translated to: $($UpdateChannel)"
21 | $OfficeC2RClientPath = Join-Path -Path $env:CommonProgramW6432 -ChildPath "Microsoft Shared\ClickToRun\OfficeC2RClient.exe"
22 | $C2RConfiguration = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration"
23 | $CurrentUpdateChannel = Get-ItemProperty -Path $C2RConfiguration | Select-Object -ExpandProperty CDNBaseUrl
24 | if ($CurrentUpdateChannel -notlike $UpdateChannel) {
25 | Write-Output -InputObject "Current update channel does not match specified update channel, calling procedure to change update channel"
26 |
27 | # Update registy configuration for new update channel
28 | Set-ItemProperty -Path $C2RConfiguration -Name "UpdateChannel" -Value $UpdateChannel -Force
29 | Write-Output -InputObject "Updated registry configuration with new update channel data endpoint"
30 |
31 | # Call OfficeC2RClient.exe and change the update channel
32 | $OfficeC2RClientParameters = "/changesetting channel=$($UpdateChannelName)"
33 | Write-Output -InputObject "Calling OfficeC2RClient.exe with the following parameters: $($OfficeC2RClientParameters)"
34 | Start-Process -FilePath $OfficeC2RClientPath -ArgumentList $OfficeC2RClientParameters -Wait
35 |
36 | # Call OfficeC2RClient.exe and update Office applications
37 | $OfficeC2RClientParameters = "/update user updateprompt=false forceappshutdown=true displaylevel=true"
38 | Write-Output -InputObject "Calling OfficeC2RClient.exe with the following parameters: $($OfficeC2RClientParameters)"
39 | Start-Process -FilePath $OfficeC2RClientPath -ArgumentList $OfficeC2RClientParameters
40 |
41 | # Trigger hardware inventory
42 | Invoke-WmiMethod -Namespace "root\ccm" -Class "SMS_Client" -Name "TriggerSchedule" -ArgumentList "{00000000-0000-0000-0000-000000000001}"
43 | }
44 | else {
45 | Write-Output -InputObject "Current update channel matches specified update channel, will not attempt to change update channel"
46 | }
--------------------------------------------------------------------------------
/Application/ConvertFrom-CMApplicationCIUniqueID.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 | Convert a CI Unique ID to Application Name and Version in ConfigMgr 2012
4 | .DESCRIPTION
5 | This script will convert a CI Unique ID shown in for example the AppIntentEval.log client log file to an Application Name and Version in ConfigMgr 2012
6 | .PARAMETER SiteServer
7 | Site server name with SMS Provider installed
8 | .PARAMETER CIUniqueID
9 | Specify the CI_UniqueID for the application to be translated
10 | .EXAMPLE
11 | .\ConvertFrom-CMApplicationCIUniqueID.ps1 -SiteServer CM01 -CIUniqueID "Application_f7cdd400-ed5a-473b-a1ce-d3a0cc6643d2" -Verbose
12 | Converts the CI Unique ID (part of) 'Application_f7cdd400-ed5a-473b-a1ce-d3a0cc6643d2' on a Primary Site server called 'CM01':
13 | .NOTES
14 | Script name: ConvertFrom-CMApplicationCIUniqueID.ps1
15 | Author: Nickolaj Andersen
16 | Contact: @NickolajA
17 | DateCreated: 2015-02-10
18 | #>
19 | [CmdletBinding(SupportsShouldProcess=$true)]
20 | [OutputType([PSObject])]
21 | param(
22 | [parameter(Mandatory=$true, HelpMessage="Site server where the SMS Provider is installed")]
23 | [ValidateScript({Test-Connection -ComputerName $_ -Count 1 -Quiet})]
24 | [ValidateNotNullOrEmpty()]
25 | [string]$SiteServer,
26 | [parameter(Mandatory=$true, HelpMessage="Specify the CI_UniqueID for the application to be translated")]
27 | [ValidateNotNullOrEmpty()]
28 | [string[]]$CIUniqueID
29 | )
30 | Begin {
31 | # Determine SiteCode from WMI
32 | try {
33 | Write-Verbose "Determining SiteCode for Site Server: '$($SiteServer)'"
34 | $SiteCodeObjects = Get-WmiObject -Namespace "root\SMS" -Class SMS_ProviderLocation -ComputerName $SiteServer -ErrorAction Stop
35 | foreach ($SiteCodeObject in $SiteCodeObjects) {
36 | if ($SiteCodeObject.ProviderForLocalSite -eq $true) {
37 | $SiteCode = $SiteCodeObject.SiteCode
38 | Write-Debug "SiteCode: $($SiteCode)"
39 | }
40 | }
41 | }
42 | catch [Exception] {
43 | Throw "Unable to determine SiteCode"
44 | }
45 | }
46 | Process {
47 | $ResultsList = New-Object -TypeName System.Collections.ArrayList
48 | foreach ($ID in $CIUniqueID) {
49 | Write-Verbose -Message "Query: SELECT * FROM SMS_ApplicationLatest WHERE CI_UniqueID like '%$($ID)%'"
50 | $Application = Get-WmiObject -Namespace "root\SMS\site_$($SiteCode)" -Class "SMS_ApplicationLatest" -ComputerName $SiteServer -Filter "CI_UniqueID like '%$($ID)%'"
51 | if ($Application -ne $null) {
52 | $PSObject = [PSCustomObject]@{
53 | DisplayName = $Application.LocalizedDisplayName
54 | Version = $Application.SoftwareVersion
55 | CI_UniqueID = $Application.CI_UniqueID
56 | }
57 | $ResultsList.Add($PSObject) | Out-Null
58 | }
59 | else {
60 | Write-Verbose -Message "Unable to find an application matching the CI_UniqueID with '$($ID)'"
61 | }
62 | }
63 | Write-Output $ResultsList
64 | }
--------------------------------------------------------------------------------
/Operating System Deployment/Invoke-TSDumpVariables.ps1:
--------------------------------------------------------------------------------
1 | # Functions
2 | function Write-CMLogEntry {
3 | param (
4 | [parameter(Mandatory = $true, HelpMessage = "Value added to the log file.")]
5 | [ValidateNotNullOrEmpty()]
6 | [string]$Value,
7 |
8 | [parameter(Mandatory = $true, HelpMessage = "Severity for the log entry. 1 for Informational, 2 for Warning and 3 for Error.")]
9 | [ValidateNotNullOrEmpty()]
10 | [ValidateSet("1", "2", "3")]
11 | [string]$Severity,
12 |
13 | [parameter(Mandatory = $false, HelpMessage = "Name of the log file that the entry will written to.")]
14 | [ValidateNotNullOrEmpty()]
15 | [string]$FileName = "TSVarDump.log"
16 | )
17 | # Determine log file location
18 | $LogFilePath = Join-Path -Path $Script:TSEnvironment.Value("_SMSTSLogPath") -ChildPath $FileName
19 |
20 | # Construct time stamp for log entry
21 | $Time = -join @((Get-Date -Format "HH:mm:ss.fff"), "+", (Get-WmiObject -Class Win32_TimeZone | Select-Object -ExpandProperty Bias))
22 |
23 | # Construct date for log entry
24 | $Date = (Get-Date -Format "MM-dd-yyyy")
25 |
26 | # Construct context for log entry
27 | $Context = $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)
28 |
29 | # Construct final log entry
30 | $LogText = "