├── Add-UsertoCollection.ps1 ├── AddDevicetoCollection.ps1 ├── AddMBAMRegEntries.reg ├── Config Item - Detect FireFox ├── ConfigItem-DetectFireFox ├── ConfigItem-ServerManager-Discovery.ps1 ├── ConfigItem-ServerManager-Remediation.ps1 ├── ConfigItem-Win10-Discovery-ShowRunAsDifferentuserinStart.ps1 ├── ConfigItem-Win10-Remediation-ShowRunAsDifferentuserinStart.ps1 ├── ConfigureFireFox.ps1 ├── Convert-UserCollectiontoDeviceCollection.ps1 ├── Dell-RootCertInfo.txt ├── Dell_Enable_TPM_Step1of2.ps1 ├── Dell_Enable_TPM_Step2of2.ps1 ├── Distribute_all_Applications_to_a_Distribution_Point_Group.ps1 ├── Distribute_all_Packages_to_a_Distribution_Point_Group.ps1 ├── Distribute_all_non-distributed_Applications_to_a_Distribution_Point_Group.ps1 ├── Distribute_all_non-distributed_Packages_to_a_Distribution_Point_Group.ps1 ├── EnableDotNet3.5.ps1 ├── Get-CMInstalledSoftware.ps1 ├── Get-MaintenanceWindows.ps1 ├── ImportDrivers.ps1 ├── Install-Fonts.ps1 ├── InstallConfigMgrPreReq1.4.1.ps1 ├── InstallDriverWinPE.ps1 ├── LaunchICEasAdmin.ps1 ├── LaunchPSasAdmin.ps1 ├── README.md ├── Refresh-DP_Missing_Content.ps1 ├── RefreshPackageonAllDPs.ps1 ├── RefreshPackageonSingleDP.ps1 ├── RemoveMBAMRegEntries.reg ├── Restart-WDS.ps1 ├── Schedule_Distribution_of_all_applications_to_DP_Group.ps1 ├── SecurePWChangeAcrossWholeENV.ps1 ├── SetTPMPolicy.wsf ├── StartMBAMEncryption.wsf ├── StartMBAMEncryptionReg.wsf ├── deletecomputer.ps1 └── discoveryitem-lms.ps1 /Add-UsertoCollection.ps1: -------------------------------------------------------------------------------- 1 | #Load Configuration Manager PowerShell Module 2 | Import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1') 3 | 4 | #Get SiteCode 5 | $SiteCode = Get-PSDrive -PSProvider CMSITE 6 | Set-location $SiteCode":" 7 | 8 | $ErrorActionPreference= 'silentlycontinue' 9 | #Collection must pre-exist 10 | $CollectionName = "Test" 11 | #List of names must pre-exist 12 | $Users = get-content "E:\Old\Scripts\Scripts\SCCM\Add User to Collection\users.txt" 13 | Foreach ($User in $Users) 14 | {Add-CMUserCollectionDirectMembershipRule -collectionname $CollectionName -resourceid (Get-CMUser -name $User).ResourceID} -------------------------------------------------------------------------------- /AddDevicetoCollection.ps1: -------------------------------------------------------------------------------- 1 | #Load Configuration Manager PowerShell Module 2 | Import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1') 3 | 4 | #Get SiteCode 5 | $SiteCode = Get-PSDrive -PSProvider CMSITE 6 | Set-location $SiteCode":" 7 | 8 | $ErrorActionPreference= 'silentlycontinue' 9 | 10 | #Collection must be pre-exist in SCCM. 11 | $CollectionName = "Import 101" 12 | #File must pre-exist in directory 13 | $Computers = get-content "D:\ad\Scripts\SCCM\Add Device to Collection\import.txt" 14 | Foreach ($Computer in $Computers) 15 | {add-cmdevicecollectiondirectmembershiprule -collectionname $CollectionName -resourceid (Get-CMDevice -name $Computer).ResourceID} -------------------------------------------------------------------------------- /AddMBAMRegEntries.reg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thestardawg/ConfigMgr/7f195f7eecc918b466b8a560ab6fb8e092f62f31/AddMBAMRegEntries.reg -------------------------------------------------------------------------------- /Config Item - Detect FireFox: -------------------------------------------------------------------------------- 1 | if (Test-Path "C:\Program Files (x86)\Mozilla Firefox") 2 | { 3 | $Installed = Test-Path "C:\Program Files (x86)\Mozilla Firefox\firefox.exe” 4 | #if (Test-Path “C:\Program Files (x86)\Mozilla Firefox\firefox.exe”) 5 | if ( $Installed -eq "$True" ) 6 | { 7 | "FireFox x86 is Installed but Certs are Not Compliant" 8 | Write-Host “NotCompliant" 9 | } 10 | Else 11 | { 12 | "FireFox x86 is Not Installed" 13 | Write-Host “Compliant” 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ConfigItem-DetectFireFox: -------------------------------------------------------------------------------- 1 | String Version 2 | 3 | if (Test-Path "C:\Program Files (x86)\Mozilla Firefox") 4 | { 5 | $Installed = Test-Path "C:\Program Files (x86)\Mozilla Firefox\firefox.exe” 6 | #if (Test-Path “C:\Program Files (x86)\Mozilla Firefox\firefox.exe”) 7 | if ( $Installed -eq "$True" ) 8 | { 9 | "FireFox x86 is Installed but Certs are Not Compliant" 10 | Write-Host “NotCompliant" 11 | } 12 | Else 13 | { 14 | "FireFox x86 is Not Installed" 15 | Write-Host “Compliant” 16 | } 17 | } 18 | 19 | Boolean 20 | $Firefox = Get-WmiObject -namespace root\cimv2\sms -class SMS_InstalledSoftware -filter "ARPDisplayName LIKE '%Firefox%'" 21 | if($Firefox){return $true}else{return $false} 22 | -------------------------------------------------------------------------------- /ConfigItem-ServerManager-Discovery.ps1: -------------------------------------------------------------------------------- 1 | $regkey = 'HKCU\Software\Microsoft\ServerManager' 2 | $name = 'DoNotOpenServerManagerAtLogon' 3 | $Compliance = 'Compliant' 4 | $Check = Get-ItemProperty -Path "$regkey" -Name "$name" -ErrorAction SilentlyContinue 5 | If ($Check) {$Compliance = 'Non-Compliant'} 6 | $Compliance -------------------------------------------------------------------------------- /ConfigItem-ServerManager-Remediation.ps1: -------------------------------------------------------------------------------- 1 | Get-Item HKCU:\Software\Microsoft\ServerManager 2 | Get-ItemProperty -Path HKCU:\Software\Microsoft\ServerManager -Name DoNotOpenServerManagerAtLogon | select DoNot OpenServerManagerAtLogon | Ft –AutoSize 3 | New-ItemProperty -Path HKCU:\Software\Microsoft\ServerManager -Name DoNotOpenServerManagerAtLogon -PropertyType DWORD -Value “0x1” –Force -------------------------------------------------------------------------------- /ConfigItem-Win10-Discovery-ShowRunAsDifferentuserinStart.ps1: -------------------------------------------------------------------------------- 1 | $regkey = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer' 2 | $name = 'ShowRunAsDifferentuserinStart' 3 | $Compliance = 'Compliant' 4 | $Check = Get-ItemProperty -Path "$regkey" -Name "$name" -ErrorAction SilentlyContinue 5 | If ($Check) {$Compliance = 'Non-Compliant'} 6 | $Compliance -------------------------------------------------------------------------------- /ConfigItem-Win10-Remediation-ShowRunAsDifferentuserinStart.ps1: -------------------------------------------------------------------------------- 1 | Get-Item HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer 2 | Get-ItemProperty -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ShowRunAsDifferentuserinStart | select ShowRunAsDifferentuserinStart | Ft –AutoSize 3 | New-ItemProperty -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name ShowRunAsDifferentuserinStart -PropertyType DWORD -Value “0x1” –Force -------------------------------------------------------------------------------- /ConfigureFireFox.ps1: -------------------------------------------------------------------------------- 1 | #Author 2 | #06-20-2016 3 | #Script to utilize SCCM Config Item to Configure Firefox 4 | #Variables 5 | $script:temp = "$Env:WinDir\Temp\" 6 | $script:local = "C:\Program Files (x86)\Mozilla Firefox\defaults\pref" 7 | $script:config = "C:\Program Files (x86)\Mozilla Firefox" 8 | $script:scriptDir = "\\cm01\Config" 9 | 10 | function script:Installed { 11 | If (Test-Path "C:\Program Files (x86)\Mozilla Firefox\firefox.exe"){ 12 | $script:Inst = $True 13 | } 14 | Elseif (Test-Path "C:\Program Files\Mozilla Firefox\firefox.exe"){ 15 | $script:Inst = $True 16 | } 17 | Else { 18 | $script:Inst = $False 19 | } 20 | } #end Installed 21 | function script:AddConfig { 22 | If ($Inst){ 23 | #del $temp\FirefoxTools -Recurse -Force -ErrorAction SilentlyContinue 24 | new-item "$Env:WinDir\Temp\FireFoxConfig" -itemtype directory | Out-null 25 | cp $scriptDir\*.cfg "C:\Windows\Temp\FireFoxConfig" 26 | cp $scriptDir\*.js "C:\Windows\Temp\FireFoxConfig" 27 | cp $temp\FireFoxConfig\mozilla.cfg $config 28 | cp $temp\FireFoxConfig\local-settings.js $local 29 | del $temp\FireFoxConfig -Recurse -Force 30 | } #endif 31 | } #end AddCert 32 | Installed #Run function 33 | AddConfig #Run function 34 | -------------------------------------------------------------------------------- /Convert-UserCollectiontoDeviceCollection.ps1: -------------------------------------------------------------------------------- 1 | #Load Configuration Manager PowerShell Module 2 | Import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1') 3 | 4 | #Get SiteCode 5 | $SiteCode = Get-PSDrive -PSProvider CMSITE 6 | Set-location $SiteCode":" 7 | 8 | $ErrorActionPreference= 'silentlycontinue' 9 | 10 | #Convert List of Users to Device Collection 11 | $list = Get-Content "E:\Old\Scripts\Scripts\SCCM\Convert User Collection To Device Collection\users.txt" 12 | $deviceresourceids = $list | foreach {Get-CMUserDeviceAffinity -username $_ | select -ExpandProperty ResourceID} 13 | $deviceresourceids | foreach {Add-CMDeviceCollectionDirectMembershipRule -CollectionName "ImportSanity" -ResourceId $_} -------------------------------------------------------------------------------- /Dell-RootCertInfo.txt: -------------------------------------------------------------------------------- 1 | Subject: "CN=eDellRoot" 2 | Issuer: "CN=eDellRoot" 3 | Serial Number: 4 | 6b:c5:7b:95:18:93:aa:97:4b:62:4a:c0:88:fc:3b:b6 5 | Fingerprint (SHA-256): 6 | EC:30:C9:C3:06:5A:06:BB:07:DC:5B:1C:6B:49:7F:37:0C:1C:A6:5C:0F:30:C0:8E:04:2B:A6:BC:EC:C7:8F:2C 7 | Fingerprint (SHA1): 8 | 98:A0:4E:41:63:35:77:90:C4:A7:9E:6D:71:3F:F0:AF:51:FE:69:27 9 | 10 | 11 | (b) 12 | https://github.com/hannob/superfishy/blob/master/certificates/DSDTestProvider.crt 13 | 14 | Subject: "CN=DSDTestProvider,O=DSDTestProvider,OU=DSDTestProvider" 15 | Issuer: "CN=DSDTestProvider,O=DSDTestProvider,OU=DSDTestProvider" 16 | Serial Number: 17 | a4:4c:38:47:f8:ee:71:80:43:4d:b1:80:b9:a7:e9:62 18 | Fingerprint (SHA-256): 19 | 0F:91:2F:D7:BE:76:0B:E2:5A:FB:C5:6B:DC:09:CD:9E:5D:CC:9C:6F:6A:55:A7:78:AE:FC:B6:AA:30:E3:15:54 20 | Fingerprint (SHA1): 21 | 02:C2:D9:31:06:2D:7B:1D:C2:A5:C7:F5:F0:68:50:64:08:1F:B2:21 -------------------------------------------------------------------------------- /Dell_Enable_TPM_Step1of2.ps1: -------------------------------------------------------------------------------- 1 | # create the SCCM tasksequence object 2 | $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment 3 | 4 | ############# Define variables ################ 5 | 6 | # Query the wmi of the computer for the status of the TPM chip 7 | if ((Get-WmiObject -class Win32_Tpm -namespace "root\CIMV2\Security\MicrosoftTpm").IsOwned_InitialValue){ 8 | $tsenv.Value("TPMIsOwned")="True" 9 | } 10 | if ((Get-WmiObject -class Win32_Tpm -namespace "root\CIMV2\Security\MicrosoftTpm").IsActivated_InitialValue){ 11 | $tsenv.Value("TPMIsActive")="True" 12 | } -------------------------------------------------------------------------------- /Dell_Enable_TPM_Step2of2.ps1: -------------------------------------------------------------------------------- 1 | $TPM = Get-WmiObject -Class Win32_TPM -Namespace root\CIMV2\Security\MicrosoftTpm 2 | 3 | # Enable, activate the chip, and allow the installation of a TPM owner. 4 | $TPM.SetPhysicalPresenceRequest(10) 5 | 6 | If(!(($TPM.IsEndorsementKeyPairPresent()).IsEndorsementKeyPairPresent)){ 7 | 8 | # Enable the TPM encryption 9 | $TPM.CreateEndorsementKeyPair() 10 | 11 | } 12 | 13 | # Check if the TPM chip currently has an owner 14 | If(($TPM.IsEndorsementKeyPairPresent()).IsEndorsementKeyPairPresent){ 15 | 16 | # Convert password to hash 17 | $OwnerAuth=$TPM.ConvertToOwnerAuth(“YourPassword”) 18 | 19 | # Clear current owner 20 | $TPM.Clear($OwnerAuth.OwnerAuth) 21 | 22 | # Take ownership 23 | $TPM.TakeOwnership($OwnerAuth.OwnerAuth) 24 | } -------------------------------------------------------------------------------- /Distribute_all_Applications_to_a_Distribution_Point_Group.ps1: -------------------------------------------------------------------------------- 1 | $SiteServer = "cm01" 2 | $SiteCode = "" 3 | $DistributionGroup = "Data Centers" 4 | 5 | $ModulePath = (($env:SMS_ADMIN_UI_PATH).Substring(0,$env:SMS_ADMIN_UI_PATH.Length-5)) + '\ConfigurationManager.psd1' 6 | Import-Module $ModulePath -Force 7 | if ((Get-PSDrive $SiteCode -ErrorAction SilentlyContinue | Measure-Object).Count -ne 1) { 8 | New-PSDrive -Name $SiteCode -PSProvider "AdminUI.PS.Provider\CMSite" -Root $SiteServer 9 | } 10 | $SiteDrive = $SiteCode + ":" 11 | Set-Location $SiteDrive 12 | 13 | $Applications = Get-WmiObject -ComputerName $SiteServer -Namespace root\SMS\site_$SiteCode -class SMS_Application | Where-Object {$_.IsLatest -eq $True} 14 | $Applications | ForEach-Object { 15 | $AppName = $_.LocalizedDisplayName 16 | Write-Output "Starting distribution of: $($AppName)" 17 | Start-CMContentDistribution -ApplicationName $AppName -DistributionPointGroupName $DistributionGroup | Out-Null 18 | } 19 | 20 | Set-Location C: 21 | -------------------------------------------------------------------------------- /Distribute_all_Packages_to_a_Distribution_Point_Group.ps1: -------------------------------------------------------------------------------- 1 | $SiteServer = "cm01" 2 | $SiteCode = "" 3 | $DistributionGroup = "Data Centers" 4 | 5 | $ModulePath = (($env:SMS_ADMIN_UI_PATH).Substring(0,$env:SMS_ADMIN_UI_PATH.Length-5)) + '\ConfigurationManager.psd1' 6 | Import-Module $ModulePath -Force 7 | if ((Get-PSDrive $SiteCode -ErrorAction SilentlyContinue | Measure-Object).Count -ne 1) { 8 | New-PSDrive -Name $SiteCode -PSProvider "AdminUI.PS.Provider\CMSite" -Root $SiteServer 9 | } 10 | $SiteDrive = $SiteCode + ":" 11 | Set-Location $SiteDrive 12 | 13 | $Packages = Get-WmiObject -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_Package -ComputerName $SiteServer 14 | $Packages | ForEach-Object { 15 | $PackageName = $_.Name 16 | Write-Output "Starting distribution of: $($PackageName)" 17 | Start-CMContentDistribution -PackageName $PackageName -DistributionPointGroupName $DistributionGroup | Out-Null 18 | } 19 | 20 | Set-Location C: 21 | -------------------------------------------------------------------------------- /Distribute_all_non-distributed_Applications_to_a_Distribution_Point_Group.ps1: -------------------------------------------------------------------------------- 1 | $SiteServer = "cm01" 2 | $SiteCode = "" 3 | $DistributionGroup = "Data Centers" 4 | 5 | $ModulePath = (($env:SMS_ADMIN_UI_PATH).Substring(0,$env:SMS_ADMIN_UI_PATH.Length-5)) + '\ConfigurationManager.psd1' 6 | Import-Module $ModulePath -Force 7 | if ((Get-PSDrive $SiteCode -ErrorAction SilentlyContinue | Measure-Object).Count -ne 1) { 8 | New-PSDrive -Name $SiteCode -PSProvider "AdminUI.PS.Provider\CMSite" -Root $SiteServer 9 | } 10 | $SiteDrive = $SiteCode + ":" 11 | Set-Location $SiteDrive 12 | 13 | $i = 0 14 | $DPGroupArray = @() 15 | $AppsToDistribute = @() 16 | 17 | $DPGroupStatus = Get-WmiObject -ComputerName $SiteServer -Namespace root\SMS\site_$SiteCode -class SMS_DPGroupDistributionStatusDetails -Filter "ObjectType = 512 AND MessageState = 1 OR MessageState = 2" | Select-Object ObjectID 18 | $DPGroupStatus | ForEach-Object { 19 | $i++ 20 | $ObjectID = $_.ObjectID 21 | Write-Progress -id 1 -Activity "Getting Status Messages from Distribution Point Group" -Status "Adding object $($i) of $($DPGroupStatus.Count) to array" -PercentComplete (($i / $DPGroupStatus.Count)*100) 22 | $DPGroupArray += $ObjectID 23 | } 24 | 25 | $Applications = Get-WmiObject -ComputerName $SiteServer -Namespace root\SMS\site_$SiteCode -class SMS_Application | Where-Object {$_.IsLatest -eq $True} 26 | $Applications | ForEach-Object { 27 | $AppName = $_.LocalizedDisplayName 28 | $ModelName = $_.ModelName 29 | if ($DPGroupArray -notcontains $ModelName ) { 30 | $AppsToDistribute += $ModelName 31 | } 32 | } 33 | 34 | if ($AppsToDistribute.Count -ge 1) { 35 | Write-Output "Found a total of $($AppsToDistribute.Count) Applications to distribute:`n" 36 | $AppsToDistribute | ForEach-Object { 37 | $ID = $_ 38 | $CurrentAppName = (Get-WmiObject -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_Application -ComputerName $SiteServer | Where-Object { $_.ModelName -like "$($ID)" }).LocalizedDisplayName 39 | Write-Output "Distributing: $($CurrentAppName)" 40 | Start-CMContentDistribution -ApplicationName $CurrentAppName -DistributionPointGroupName $DistributionGroup | Out-Null 41 | } 42 | } 43 | else { 44 | Write-Output "Distribution Point Group: $($DistributionGroup)" 45 | Write-Output "Results: No undistributed Applications found" 46 | } 47 | 48 | Set-Location C: 49 | -------------------------------------------------------------------------------- /Distribute_all_non-distributed_Packages_to_a_Distribution_Point_Group.ps1: -------------------------------------------------------------------------------- 1 | $SiteServer = "cm01" 2 | $SiteCode = "" 3 | $DistributionGroup = "Data Centers" 4 | 5 | $ModulePath = (($env:SMS_ADMIN_UI_PATH).Substring(0,$env:SMS_ADMIN_UI_PATH.Length-5)) + '\ConfigurationManager.psd1' 6 | Import-Module $ModulePath -Force 7 | if ((Get-PSDrive $SiteCode -ErrorAction SilentlyContinue | Measure-Object).Count -ne 1) { 8 | New-PSDrive -Name $SiteCode -PSProvider "AdminUI.PS.Provider\CMSite" -Root $SiteServer 9 | } 10 | $SiteDrive = $SiteCode + ":" 11 | Set-Location $SiteDrive 12 | 13 | $PackageIDs = @() 14 | $PackagesToDistribute = @() 15 | 16 | $DPGroupPackages = Get-WmiObject -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_DPGroupPackages -ComputerName $SiteServer 17 | $DPGroupPackages | ForEach-Object { 18 | $DPGroupPackageID = $_.PkgID 19 | $PackageIDs += $DPGroupPackageID 20 | } 21 | 22 | $Packages = Get-WmiObject -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_Package -ComputerName $SiteServer 23 | $Packages | ForEach-Object { 24 | $PackageID = $_.PackageID 25 | $PackageName = $_.Name 26 | if ($PackageIDs -notcontains $PackageID ) { 27 | $PackagesToDistribute += $PackageID 28 | } 29 | } 30 | 31 | if ($PackagesToDistribute.Count -ge 1) { 32 | Write-Output "Found a total of $($PackagesToDistribute.Count) Packages to distribute:`n" 33 | $PackagesToDistribute | ForEach-Object { 34 | $ID = $_ 35 | $CurrentPackageName = (Get-WmiObject -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_Package -ComputerName $SiteServer | Where-Object { $_.PackageID -like "$($ID)" }).Name 36 | Write-Output "Distributing: $($CurrentPackageName)" 37 | Start-CMContentDistribution -PackageName $CurrentPackageName -DistributionPointGroupName $DistributionGroup | Out-Null 38 | } 39 | } 40 | else { 41 | Write-Output "Distribution Point Group: $($DistributionGroup)" 42 | Write-Output "Results: No undistributed Packages found" 43 | } 44 | 45 | Set-Location C: 46 | -------------------------------------------------------------------------------- /EnableDotNet3.5.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Synopsis 3 | Enables the .NET Framework Feature on Windows 8.1 4 | .DESCRIPTION 5 | Enables the .NET Framework Feature on Windows 8.1 using a copy of the \sources\sxs folder 6 | content from the Windows 8.1 installation media 7 | .PARAMETER Source 8 | Optional parameter pointing to the location where the SXS files are located, if no -Source 9 | parameter is provided, the SXS folder is expected to be in the same folder as the script. 10 | .EXAMPLE 11 | Enable-NET35SP1.ps1 12 | .EXAMPLE 13 | Enable-NET35SP1.ps1 -Source R:\Win81\Sources\sxs 14 | .LINK 15 | 16 | .NOTES 17 | Version 1.0, by Alex Verboon 18 | #> 19 | 20 | [CmdletBinding(SupportsShouldProcess=$true)] 21 | Param( 22 | [Parameter(Mandatory=$false, 23 | ValueFromPipelineByPropertyName=$true, 24 | ParameterSetName="SXSPath", 25 | HelpMessage= 'SXS Folder')] 26 | [String]$Source 27 | ) 28 | 29 | 30 | Begin{ 31 | If ((Get-windowsoptionalfeature -FeatureName NetFx3 -Online | Select-Object -ExpandProperty State) -ne "Enabled") 32 | { 33 | Write-Verbose ".NET Framework 3.5SP1 is not enabled on this system" 34 | if ([string]::IsNullOrEmpty($Source)) 35 | { 36 | #No source path provided so set source path to SXS folder located in the script execution path 37 | # we'll check later if it actually exists 38 | $PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition 39 | $SxsSource = "$PSScriptRoot\SXS" 40 | } 41 | else 42 | { 43 | # set the Source to the provided path, we'll check later if it exists 44 | $SxsSource = $Source 45 | } 46 | } 47 | Else 48 | { 49 | Write-Output ".NET Framework 3.5 SP1 is already installed" 50 | Exit 51 | } 52 | } 53 | 54 | 55 | Process{ 56 | If ((Test-Path -Path "$SxsSource") -eq $false) 57 | { 58 | Write-Error "SXS Sources: SxsSource not found" 59 | } 60 | Else 61 | { 62 | Write-Verbose "SXS Sources: $SxsSource found" 63 | If ($PScmdlet.ShouldProcess("Enabling .NET Framework 3.5 Feature using Sources in $SxsSource","","")) 64 | { 65 | Write-Output "Enabling .NET Framework 3.5 Feature" 66 | enable-windowsoptionalfeature -featurename NetFx3 -Online -NoRestart -LimitAccess -All -Source $SxsSource -LogLevel WarningsInfo -ErrorAction Continue 67 | } 68 | } 69 | } 70 | 71 | 72 | End{ 73 | If ((Get-windowsoptionalfeature -FeatureName NetFx3 -Online | Select-Object -ExpandProperty State) -eq "Enabled") 74 | { 75 | Write-Output "Enabling .NET Framework 3.5 SP1 completed " 76 | } 77 | Else 78 | { 79 | Write-Output "Enabling .NET Framework 3.5 SP1 not completed" 80 | } 81 | } -------------------------------------------------------------------------------- /Get-CMInstalledSoftware.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding(SupportsShouldProcess=$True)] 2 | param 3 | ( 4 | [Parameter(Mandatory=$False,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] 5 | [string]$SoftwareName = "%", 6 | [Parameter(Mandatory=$False)] 7 | [switch]$Count, 8 | [Parameter(Mandatory=$False)] 9 | [switch]$CSV, 10 | [Parameter(Mandatory=$False)] 11 | [string]$SQLServer = “1ndcitvwcm01.tsi.lan”, # eg, , or \ 12 | [Parameter(Mandatory=$False)] 13 | [string]$Database = “CM_TAB” 14 | ) 15 | 16 | # Open a connection 17 | $connectionString = “Server=$SQLServer;Database=$database;Integrated Security=SSPI;” 18 | $connection = New-Object System.Data.SqlClient.SqlConnection 19 | $connection.ConnectionString = $connectionString 20 | $connection.Open() 21 | 22 | # Set queries 23 | if ($count) 24 | { 25 | $query = " 26 | SELECT Count(sof.NormalizedName) AS 'Count', 27 | sof.NormalizedName, sof.NormalizedVersion, sof.NormalizedPublisher, sof.FamilyName, sof.CategoryName 28 | FROM v_GS_INSTALLED_SOFTWARE_CATEGORIZED sof 29 | where sof.NormalizedName like '$SoftwareName' 30 | GROUP BY sof.NormalizedName, sof.NormalizedVersion, sof.NormalizedPublisher, sof.FamilyName, sof.CategoryName 31 | ORDER BY 'Count' DESC, sof.NormalizedName, sof.NormalizedVersion 32 | " 33 | } 34 | else 35 | { 36 | $query = "select Name0 as 'Computer Name', 37 | User_Name0 as 'Last Logged-On User', 38 | NormalizedName as 'Software Name', 39 | NormalizedPublisher as Publisher, 40 | NormalizedVersion as Version, 41 | FamilyName as 'Software Family', 42 | CategoryName as 'Software Category', 43 | InstallDate0 as 'Install Date', 44 | RegisteredUser0 as 'Registered User', 45 | InstalledLocation0 as 'Install Location', 46 | InstallSource0 as 'Source Location', 47 | UninstallString0 as 'Uninstall String', 48 | TimeStamp as 'Inventory Time' 49 | from v_GS_INSTALLED_SOFTWARE_CATEGORIZED sof 50 | inner join v_R_System sys on sof.ResourceID = sys.ResourceID 51 | where sof.NormalizedName like '$SoftwareName' order by Name0 52 | " 53 | } 54 | 55 | $command = $connection.CreateCommand() 56 | $command.CommandText = $query 57 | $result = $command.ExecuteReader() 58 | 59 | $table = new-object “System.Data.DataTable” 60 | $table.Load($result) 61 | 62 | # Output results 63 | if ($CSV) 64 | { 65 | $Path = "$env:TEMP\SoftwareQuery-$(Get-date -format hh-mm).csv" 66 | $table | Export-Csv -Path $Path -Force -NoTypeInformation 67 | Invoke-Item $Path 68 | } 69 | Else {$table} 70 | 71 | # Close the connection 72 | $connection.Close() 73 | 74 | # Usage Examples. Needs to be loaded as function first. 75 | #.\getcminstalledsoftware.ps1 -SoftwareName "Microsoft Project%" -CSV 76 | #.\getcminstalledsoftware.ps1 -SoftwareName "Microsoft Visio%" | Out-GridView -------------------------------------------------------------------------------- /Get-MaintenanceWindows.ps1: -------------------------------------------------------------------------------- 1 | [CmdletBinding()] 2 | param( 3 | [parameter(Mandatory=$true)] 4 | $SiteServer, 5 | [parameter(Mandatory=$true)] 6 | $SiteCode, 7 | [parameter(Mandatory=$true)] 8 | $ResourceID 9 | ) 10 | 11 | function Load-Form { 12 | $Form.Controls.Add($DGVResults1) 13 | $Form.Controls.Add($DGVResults2) 14 | $Form.Controls.Add($GBMW) 15 | $Form.Controls.Add($GBMWUpcoming) 16 | $Form.Add_Shown({Get-CMMaintenanceWindowsInformation}) 17 | $Form.Add_Shown({$Form.Activate()}) 18 | [void]$Form.ShowDialog() 19 | } 20 | 21 | function Get-CMSiteCode { 22 | $CMSiteCode = Get-WmiObject -Namespace "root\SMS" -Class SMS_ProviderLocation -ComputerName $SiteServer | Select-Object -ExpandProperty SiteCode 23 | return $CMSiteCode 24 | } 25 | 26 | function Get-CMSchedule { 27 | param( 28 | $String 29 | ) 30 | $WMIConnection = [WmiClass]"\\$($SiteServer)\root\SMS\site_$(Get-CMSiteCode):SMS_ScheduleMethods" 31 | $Schedule = $WMIConnection.psbase.GetMethodParameters("ReadFromString") 32 | $Schedule.StringData = $String 33 | $ScheduleData = $WMIConnection.psbase.InvokeMethod("ReadFromString",$Schedule,$null) 34 | $ScheduleInfo = $ScheduleData.TokenData 35 | return $ScheduleInfo 36 | } 37 | 38 | function Get-CMMaintenanceWindowsInformation { 39 | $CMSiteCode = Get-CMSiteCode 40 | $CurrentDateTime = (Get-Date) 41 | $AllMWDates = @() 42 | $DateArray = @() 43 | $CollectionIDs = Get-WmiObject -Namespace "root\SMS\site_$($CMSiteCode)" -Class SMS_FullCollectionMembership -ComputerName $SiteServer -Filter "ResourceID like '$($ResourceID)'" 44 | foreach ($CollectionID in $CollectionIDs) { 45 | $CollectionSettings = Get-WmiObject -Namespace "root\SMS\site_$($CMSiteCode)" -Class SMS_CollectionSettings -ComputerName $SiteServer -Filter "CollectionID='$($CollectionID.CollectionID)'" 46 | foreach ($CollectionSetting in $CollectionSettings) { 47 | $CollectionSetting.Get() 48 | foreach ($MaintenanceWindow in $CollectionSetting.ServiceWindows) { 49 | $StartTime = [Management.ManagementDateTimeConverter]::ToDateTime($MaintenanceWindow.StartTime) 50 | $DateArray += $MaintenanceWindow 51 | $CollectionName = Get-WmiObject -Namespace "root\SMS\site_$($CMSiteCode)" -Class SMS_Collection -ComputerName $SiteServer -Filter "CollectionID = '$($CollectionID.CollectionID)'" | Select-Object -ExpandProperty Name 52 | $DGVResults1.Rows.Add($MaintenanceWindow.Name,$CollectionName) | Out-Null 53 | } 54 | } 55 | } 56 | $SortedDateArray = $DateArray | Sort-Object -Property RecurrenceType | Select-Object Description, RecurrenceType, ServiceWindowSchedules, isEnabled 57 | $RecurrenceType1 = ($SortedDateArray | Where-Object { $_.RecurrenceType -eq 1 }) 58 | if ($RecurrenceType1 -ne $null) { 59 | foreach ($R1RecurrenceType in $RecurrenceType1) { 60 | if ($R1RecurrenceType.IsEnabled -eq $true) { 61 | $R1Schedule = Get-CMSchedule -String $R1RecurrenceType.ServiceWindowSchedules 62 | $R1StartTime = [Management.ManagementDateTimeConverter]::ToDateTime($R1Schedule.StartTime) 63 | if ((Get-Date) -le $R1StartTime) { 64 | $AllMWDates += $R1StartTime 65 | } 66 | } 67 | } 68 | } 69 | $RecurrenceType2 = ($SortedDateArray | Where-Object { $_.RecurrenceType -eq 2 }) 70 | if ($RecurrenceType2 -ne $null) { 71 | foreach ($R2RecurrenceType in $RecurrenceType2) { 72 | if ($R2RecurrenceType.IsEnabled -eq $true) { 73 | $R2Schedule = Get-CMSchedule -String $R2RecurrenceType.ServiceWindowSchedules 74 | $R2StartTime = [Management.ManagementDateTimeConverter]::ToDateTime($R2Schedule.StartTime) 75 | $R2DaySpan = $R2Schedule.DaySpan 76 | $R2CurrentDate = (Get-Date) 77 | do { 78 | $R2StartTime = $R2StartTime.AddDays($R2DaySpan) 79 | } 80 | until ($R2StartTime -ge $R2CurrentDate) 81 | if ((Get-Date) -le $R2StartTime) { 82 | $AllMWDates += $R2StartTime 83 | } 84 | } 85 | } 86 | } 87 | $RecurrenceType3 = ($SortedDateArray | Where-Object { $_.RecurrenceType -eq 3 }) 88 | if ($RecurrenceType3 -ne $null) { 89 | foreach ($R3RecurrenceType in $RecurrenceType3) { 90 | if ($R3RecurrenceType.IsEnabled -eq $true) { 91 | $R3Schedule = Get-CMSchedule -String $R3RecurrenceType.ServiceWindowSchedules 92 | $R3StartMin = [Management.ManagementDateTimeConverter]::ToDateTime($R3Schedule.StartTime) | Select-Object -ExpandProperty Minute 93 | $R3StartHour = [Management.ManagementDateTimeConverter]::ToDateTime($R3Schedule.StartTime) | Select-Object -ExpandProperty Hour 94 | $R3StartDay = $R3Schedule.Day 95 | switch ($R3StartDay) { 96 | 1 { $R3DayOfWeek = "Sunday" } 97 | 2 { $R3DayOfWeek = "Monday" } 98 | 3 { $R3DayOfWeek = "Tuesday" } 99 | 4 { $R3DayOfWeek = "Wednesday" } 100 | 5 { $R3DayOfWeek = "Thursday" } 101 | 6 { $R3DayOfWeek = "Friday" } 102 | 7 { $R3DayOfWeek = "Saturday" } 103 | } 104 | $R3WeekSpan = $R3Schedule.ForNumberOfWeeks 105 | switch ($R3WeekSpan) { 106 | 1 { $R3AddDays = 0 } 107 | 2 { $R3AddDays = 7 } 108 | 3 { $R3AddDays = 14 } 109 | 4 { $R3AddDays = 21 } 110 | } 111 | $R3CurrentDate = (Get-Date) 112 | $R3DaysUntil = 0 113 | While ($R3CurrentDate.DayOfWeek -ne "$($R3DayOfWeek)") { 114 | $R3DaysUntil++ 115 | $R3CurrentDate = $R3CurrentDate.AddDays(1) 116 | } 117 | if ($R3StartHour -le 9) { 118 | if ($R3StartMin -le 9) { 119 | $R3DateTime = ([datetime]::ParseExact("0$($R3StartHour):0$($R3StartMin)","hh:mm",$null)).AddDays($R3DaysUntil).AddDays($R3AddDays) 120 | } 121 | elseif ($R3StartMin -ge 10) { 122 | $R3DateTime = ([datetime]::ParseExact("0$($R3StartHour):$($R3StartMin)","hh:mm",$null)).AddDays($R3DaysUntil).AddDays($R3AddDays) 123 | } 124 | } 125 | elseif ($R3StartHour -ge 10) { 126 | if ($R3StartMin -le 9) { 127 | $R3DateTime = ([datetime]::ParseExact("$($R3StartHour):0$($R3StartMin)","hh:mm",$null)).AddDays($R3DaysUntil).AddDays($R3AddDays) 128 | } 129 | elseif ($R3StartMin -ge 10) { 130 | $R3DateTime = ([datetime]::ParseExact("$($R3StartHour):$($R3StartMin)","hh:mm",$null)).AddDays($R3DaysUntil).AddDays($R3AddDays) 131 | } 132 | } 133 | if ((Get-Date) -le $R3DateTime) { 134 | $AllMWDates += $R3DateTime 135 | } 136 | } 137 | } 138 | } 139 | $RecurrenceType4 = ($SortedDateArray | Where-Object { $_.RecurrenceType -eq 4 }) 140 | if ($RecurrenceType4 -ne $null) { 141 | foreach ($R4RecurrenceType in $RecurrenceType4) { 142 | if ($R4RecurrenceType.IsEnabled -eq $true) { 143 | $R4Schedule = Get-CMSchedule -String $R4RecurrenceType.ServiceWindowSchedules 144 | $R4WeekOrder = $R4Schedule.WeekOrder 145 | $R4StartHour = [Management.ManagementDateTimeConverter]::ToDateTime($R4Schedule.StartTime) | Select-Object -ExpandProperty Hour 146 | $R4StartMin = [Management.ManagementDateTimeConverter]::ToDateTime($R4Schedule.StartTime) | Select-Object -ExpandProperty Minute 147 | $R4StartSec = [Management.ManagementDateTimeConverter]::ToDateTime($R4Schedule.StartTime) | Select-Object -ExpandProperty Second 148 | $R4WeekDay = $R4Schedule.Day 149 | switch ($R4WeekDay) { 150 | 1 { $R4DayOfWeek = "Sunday" } 151 | 2 { $R4DayOfWeek = "Monday" } 152 | 3 { $R4DayOfWeek = "Tuesday" } 153 | 4 { $R4DayOfWeek = "Wednesday" } 154 | 5 { $R4DayOfWeek = "Thursday" } 155 | 6 { $R4DayOfWeek = "Friday" } 156 | 7 { $R4DayOfWeek = "Saturday" } 157 | } 158 | if ($R4WeekOrder -ge 1) { 159 | $R4Increment = 0 160 | $R4Date = (Get-Date -Year (Get-Date).Year -Month (Get-Date).Month -Day 1 -Hour $($R4StartHour) -Minute $($R4StartMin) -Second $($R4StartSec)) 161 | do { 162 | $R4Increment++ 163 | $R4CalcDate = $R4Date.AddDays($R4Increment) 164 | $R4CalcDayofWeek = $R4CalcDate.DayOfWeek 165 | } 166 | until ($R4CalcDayofWeek -like $R4DayOfWeek) 167 | $R4CalcDateTime = $R4CalcDate 168 | if ($R4WeekOrder -eq 1) { 169 | $R4DateTime = $R4CalcDateTime 170 | } 171 | elseif ($R4WeekOrder -eq 2) { 172 | $R4DateTime = $R4CalcDateTime.AddDays(7) 173 | } 174 | elseif ($R4WeekOrder -eq 3) { 175 | $R4DateTime = $R4CalcDateTime.AddDays(14) 176 | } 177 | elseif ($R4WeekOrder -eq 4) { 178 | $R4DateTime = $R4CalcDateTime.AddDays(21) 179 | } 180 | } 181 | elseif ($R4WeekOrder -eq 0) { 182 | $R4Decrement = 0 183 | $R4Date = (Get-Date -Year (Get-Date).Year -Month (Get-Date).Month -Day 1 -Hour $($R4StartHour) -Minute $($R4StartMin) -Second $($R4StartSec)).AddMonths(1) 184 | do { 185 | $R4Decrement++ 186 | $R4CalcDate = $R4Date.AddDays(-$R4Decrement) 187 | $R4CalcDayofWeek = $R4CalcDate.DayOfWeek 188 | } 189 | until ($R4CalcDayofWeek -like $R4DayOfWeek) 190 | $R4DateTime = $R4CalcDate 191 | } 192 | if ((Get-Date) -le $R4DateTime) { 193 | $AllMWDates += $R4DateTime 194 | } 195 | } 196 | } 197 | } 198 | $RecurrenceType5 = ($SortedDateArray | Where-Object { $_.RecurrenceType -eq 5 }) 199 | if ($RecurrenceType5 -ne $null) { 200 | foreach ($R5RecurrenceType in $RecurrenceType5) { 201 | if ($R5RecurrenceType.IsEnabled -eq $true) { 202 | $R5Schedule = Get-CMSchedule -String $R5RecurrenceType.ServiceWindowSchedules 203 | $R5StartTime = [Management.ManagementDateTimeConverter]::ToDateTime($R5Schedule.StartTime) 204 | $R5StartHour = $R5StartTime.Hour 205 | $R5StartMin = $R5StartTime.Minute 206 | $R5StartSec = $R5StartTime.Second 207 | $R5MonthSpan = $R5Schedule.ForNumberOfMonths 208 | $R5MonthDay = $R5Schedule.MonthDay 209 | if ($R5Schedule.MonthDay -ge 1) { 210 | if ($R5MonthSpan -eq 1) { 211 | $R5DateTime = ((Get-Date -Year (Get-Date).Year -Month (Get-Date).Month -Day $($R5MonthDay) -Hour $($R5StartHour) -Minute $($R5StartMin) -Second $($R5StartSec))).DateTime 212 | } 213 | elseif ($R5MonthSpan -gt 1) { 214 | $R5DateTime = ((Get-Date -Year (Get-Date).Year -Month (Get-Date).Month -Day $($R5MonthDay) -Hour $($R5StartHour) -Minute $($R5StartMin) -Second $($R5StartSec)).AddMonths($R5MonthSpan)).DateTime 215 | } 216 | } 217 | elseif ($R5Schedule.MonthDay -eq 0) { 218 | $R5DateTime = ((Get-Date -Year (Get-Date).Year -Month (Get-Date).Month -Day 1 -Hour $($R5StartHour) -Minute $($R5StartMin) -Second $($R5StartSec)).AddMonths($R5MonthSpan).AddDays(-1)).DateTime 219 | } 220 | if ((Get-Date) -le $R5DateTime) { 221 | $AllMWDates += $R5DateTime 222 | } 223 | } 224 | } 225 | } 226 | $SortedDates = $AllMWDates | Sort-Object 227 | $SortedDates | ForEach-Object { 228 | $DGVResults2.Rows.Add($_) 229 | } 230 | } 231 | 232 | # Assemblies 233 | [void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") 234 | [void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 235 | 236 | # Form 237 | $Form = New-Object System.Windows.Forms.Form 238 | $Form.Size = New-Object System.Drawing.Size(700,470) 239 | $Form.MinimumSize = New-Object System.Drawing.Size(700,470) 240 | $Form.MaximumSize = New-Object System.Drawing.Size(700,470) 241 | $Form.SizeGripStyle = "Hide" 242 | $Form.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($PSHome + "\powershell.exe") 243 | $Form.Text = "Maintenance Window Tool 1.0" 244 | $Form.ControlBox = $true 245 | $Form.TopMost = $true 246 | 247 | # DataGriView 248 | $DGVResults1 = New-Object System.Windows.Forms.DataGridView 249 | $DGVResults1.Location = New-Object System.Drawing.Size(20,30) 250 | $DGVResults1.Size = New-Object System.Drawing.Size(640,170) 251 | $DGVResults1.ColumnCount = 2 252 | $DGVResults1.ColumnHeadersVisible = $true 253 | $DGVResults1.Columns[0].Name = "Maintenance Window Name" 254 | $DGVResults1.Columns[0].AutoSizeMode = "Fill" 255 | $DGVResults1.Columns[1].Name = "Collection Name" 256 | $DGVResults1.Columns[1].AutoSizeMode = "Fill" 257 | $DGVResults1.AllowUserToAddRows = $false 258 | $DGVResults1.AllowUserToDeleteRows = $false 259 | $DGVResults1.ReadOnly = $True 260 | $DGVResults1.ColumnHeadersHeightSizeMode = "DisableResizing" 261 | $DGVResults1.RowHeadersWidthSizeMode = "DisableResizing" 262 | $DGVResults2 = New-Object System.Windows.Forms.DataGridView 263 | $DGVResults2.Location = New-Object System.Drawing.Size(20,240) 264 | $DGVResults2.Size = New-Object System.Drawing.Size(640,170) 265 | $DGVResults2.ColumnCount = 1 266 | $DGVResults2.ColumnHeadersVisible = $true 267 | $DGVResults2.Columns[0].Name = "Upcoming Maintenance Windows" 268 | $DGVResults2.Columns[0].AutoSizeMode = "Fill" 269 | $DGVResults2.AllowUserToAddRows = $false 270 | $DGVResults2.AllowUserToDeleteRows = $false 271 | $DGVResults2.ReadOnly = $True 272 | $DGVResults2.ColumnHeadersHeightSizeMode = "DisableResizing" 273 | $DGVResults2.RowHeadersWidthSizeMode = "DisableResizing" 274 | 275 | # Groupbox 276 | $GBMW = New-Object System.Windows.Forms.GroupBox 277 | $GBMW.Location = New-Object System.Drawing.Size(10,10) 278 | $GBMW.Size = New-Object System.Drawing.Size(660,200) 279 | $GBMW.Text = "Maintenance Windows" 280 | $GBMWUpcoming = New-Object System.Windows.Forms.GroupBox 281 | $GBMWUpcoming.Location = New-Object System.Drawing.Size(10,220) 282 | $GBMWUpcoming.Size = New-Object System.Drawing.Size(660,200) 283 | $GBMWUpcoming.Text = "Upcoming Maintenance Windows" 284 | 285 | # Load form 286 | Load-Form -------------------------------------------------------------------------------- /ImportDrivers.ps1: -------------------------------------------------------------------------------- 1 | Function Get-SCCMDriverCategory 2 | { 3 | [CmdletBinding()] 4 | PARAM 5 | ( 6 | [Parameter(Position=1)] $categoryName 7 | ) 8 | 9 | # Build the appropriate filter to return all categories or just one specified by name 10 | $filter = "CategoryTypeName = 'DriverCategories'" 11 | if ($categoryName -eq "" -or $categoryName -eq $null) 12 | { 13 | Write-Debug "Retriving all categories" 14 | } 15 | else 16 | { 17 | $filter += " and LocalizedCategoryInstanceName = '" + $categoryName + "'" 18 | } 19 | 20 | # Retrieve the matching list 21 | Get-SCCMObject SMS_CategoryInstance -filter $filter 22 | } 23 | 24 | Function New-SCCMDriverCategory 25 | { 26 | [CmdletBinding()] 27 | PARAM 28 | ( 29 | [Parameter(Position=1)] $categoryName 30 | ) 31 | 32 | # Create a SMS_Category_LocalizedProperties instance 33 | $localizedClass = [wmiclass]"\\$sccmServer\$($sccmNamespace):SMS_Category_LocalizedProperties" 34 | 35 | # Populate the localized settings to be used with the new driver instance 36 | $localizedSetting = $localizedClass.psbase.CreateInstance() 37 | $localizedSetting.LocaleID = 1033 38 | $localizedSetting.CategoryInstanceName = $categoryName 39 | [System.Management.ManagementObject[]] $localizedSettings += $localizedSetting 40 | 41 | # Create the unique ID 42 | $categoryGuid = [System.Guid]::NewGuid().ToString() 43 | $uniqueID = "DriverCategories:$categoryGuid" 44 | 45 | # Build the parameters for creating the collection 46 | $arguments = @{CategoryInstance_UniqueID = $uniqueID; LocalizedInformation = $localizedSettings; SourceSite = $sccmSiteCode; CategoryTypeName = 'DriverCategories'} 47 | 48 | # Create the new instance 49 | set-wmiinstance -class SMS_CategoryInstance -arguments $arguments -computername $sccmServer -namespace $sccmNamespace 50 | } 51 | 52 | Function New-SCCMDriverPackage 53 | { 54 | [CmdletBinding()] 55 | PARAM 56 | ( 57 | [Parameter(Position=1)] $name, 58 | [Parameter(Position=2)] $description, 59 | [Parameter(Position=3)] $sourcePath 60 | ) 61 | 62 | # Build the parameters for creating the collection 63 | $arguments = @{Name = $name; Description = $description; PkgSourceFlag = 2; PkgSourcePath = $sourcePath} 64 | $newPackage = set-wmiinstance -class SMS_DriverPackage -arguments $arguments -computername $sccmServer -namespace $sccmNamespace 65 | 66 | # Hack - for some reason without this we don't get the PackageID value 67 | $hack = $newPackage.PSBase | select * | out-null 68 | 69 | # Return the package 70 | $newPackage 71 | } 72 | 73 | Function New-SCCMFolder 74 | { 75 | Param( 76 | $FolderName, 77 | $FolderType, 78 | $ParentFolderID = 0 79 | ) 80 | 81 | If ($FolderType -eq "Device") { $FolderType = 5000 } 82 | If ($FolderType -eq "User") { $FolderType = 5001 } 83 | 84 | $SMSFolderClass = "SMS_ObjectContainerNode" 85 | $Colon = ":" 86 | 87 | $WMIConnection = [WMIClass]"\\$sccmServer\$sccmNamespace$Colon$SMSFolderClass" 88 | $CreateFolder = $WMIConnection.psbase.CreateInstance() 89 | $CreateFolder.Name = $FolderName 90 | $CreateFolder.ObjectType = $FolderType 91 | $CreateFolder.ParentContainerNodeid = $ParentFolderID 92 | $FolderResult = $CreateFolder.Put() 93 | 94 | $FolderID = $FolderResult.RelativePath.Substring($FolderResult.RelativePath.Length - 8, 8) 95 | 96 | $FolderID 97 | 98 | } 99 | 100 | Function Move-SCCMObject 101 | { 102 | Param( 103 | $SourceFolderID = 0, 104 | $TargetFolderID, 105 | $ObjectID, 106 | $ObjectType 107 | ) 108 | 109 | If ($ObjectType -eq "Device") { $ObjectType = 5000 } 110 | If ($ObjectType -eq "User") { $ObjectType = 5001 } 111 | 112 | $Method = "MoveMembers" 113 | $SMSObjectClass = "SMS_ObjectContainerItem" 114 | $Colon = ":" 115 | 116 | $WMIConnection = [WMIClass]"\\$sccmServer\$sccmNamespace$Colon$SMSObjectClass" 117 | $InParams = $WMIConnection.psbase.GetMethodParameters("MoveMembers") 118 | $InParams.ContainerNodeID = $SourceFolderId 119 | $InParams.InstanceKeys = $ObjectID 120 | $InParams.ObjectType = $ObjectType 121 | $InParams.TargetContainerNodeID = $TargetFolderID 122 | $null = $WMIConnection.psbase.InvokeMethod($Method,$InParams,$null) 123 | 124 | } 125 | 126 | Function Get-ContentHash 127 | { 128 | Param ( 129 | $File, 130 | [ValidateSet("sha1","md5")] 131 | [string]$Algorithm="md5" 132 | ) 133 | 134 | $content = "$($file.Name)$($file.Length)" 135 | $algo = [type]"System.Security.Cryptography.md5" 136 | $crypto = $algo::Create() 137 | $hash = [BitConverter]::ToString($crypto.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($content))).Replace("-", "") 138 | $hash 139 | } 140 | 141 | Function Get-FolderHash 142 | { 143 | Param ( 144 | [string]$Folder=$(throw("You must specify a folder to get the checksum of.")), 145 | [ValidateSet("sha1","md5")] 146 | [string]$Algorithm="md5" 147 | ) 148 | 149 | Get-ChildItem $Folder -Recurse -Exclude "*.hash" | % { $content += Get-ContentHash $_ $Algorithm } 150 | 151 | 152 | $algo = [type]"System.Security.Cryptography.$Algorithm" 153 | $crypto = $algo::Create() 154 | $hash = [BitConverter]::ToString($crypto.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($content))).Replace("-", "") 155 | 156 | $hash 157 | } 158 | 159 | Function Write-Custom($message, [System.ConsoleColor]$foregroundcolor) 160 | { 161 | 162 | For ($i = 2; $i -le $currentDepth; $i++) 163 | { 164 | $tab += "`t" 165 | } 166 | 167 | $currentColor = $Host.UI.RawUI.ForegroundColor 168 | if ($foregroundcolor) 169 | { 170 | $Host.UI.RawUI.ForegroundColor = $foregroundcolor 171 | } 172 | if ($message) 173 | { 174 | Write-Output "$($tab)$($message)" 175 | } 176 | $Host.UI.RawUI.ForegroundColor = $currentColor 177 | } 178 | 179 | Function Write-Headline($message) 180 | { 181 | 182 | $dot = "------------------------------------------------------------------------------------------------------------" 183 | 184 | For ($i = 2; $i -le $currentDepth; $i++) 185 | { 186 | $dot = $dot.Substring(0, $dot.Length-8) 187 | } 188 | Write-Custom " " 189 | Write-Custom "$($dot)" 190 | Write-Custom "$($message)" 191 | Write-Custom "$($dot)" 192 | } 193 | 194 | Function New-SCCMConnection { 195 | 196 | [CmdletBinding()] 197 | PARAM 198 | ( 199 | [Parameter(Position=1)] $serverName, 200 | [Parameter(Position=2)] $siteCode 201 | ) 202 | 203 | 204 | # Clear the results from any previous execution 205 | 206 | Clear-Variable -name sccmServer -errorAction SilentlyContinue 207 | Clear-Variable -name sccmNamespace -errorAction SilentlyContinue 208 | Clear-Variable -name sccmSiteCode -errorAction SilentlyContinue 209 | Clear-Variable -name sccmConnection -errorAction SilentlyContinue 210 | 211 | 212 | # If the $serverName is not specified, use "." 213 | 214 | if ($serverName -eq $null -or $serverName -eq "") 215 | { 216 | $serverName = "." 217 | } 218 | 219 | 220 | # Get the pointer to the provider for the site code 221 | 222 | if ($siteCode -eq $null -or $siteCode -eq "") 223 | { 224 | Write-Verbose "Getting provider location for default site on server $serverName" 225 | $providerLocation = get-wmiobject -query "select * from SMS_ProviderLocation where ProviderForLocalSite = true" -namespace "root\sms" -computername $serverName -errorAction Stop 226 | } 227 | else 228 | { 229 | Write-Verbose "Getting provider location for site $siteName on server $serverName" 230 | $providerLocation = get-wmiobject -query "select * from SMS_ProviderLocation where SiteCode = '$siteCode'" -namespace "root\sms" -computername $serverName -errorAction Stop 231 | } 232 | 233 | 234 | # Split up the namespace path 235 | 236 | $parts = $providerLocation.NamespacePath -split "\\", 4 237 | Write-Verbose "Provider is located on $($providerLocation.Machine) in namespace $($parts[3])" 238 | $global:sccmServer = $providerLocation.Machine 239 | $global:sccmNamespace = $parts[3] 240 | $global:sccmSiteCode = $providerLocation.SiteCode 241 | 242 | 243 | # Make sure we can get a connection 244 | 245 | $global:sccmConnection = [wmi]"${providerLocation.NamespacePath}" 246 | Write-Verbose "Successfully connected to the specified provider" 247 | } 248 | 249 | function Get-SCCMObject { 250 | 251 | [CmdletBinding()] 252 | PARAM 253 | ( 254 | [Parameter(Position=1)] $class, 255 | [Parameter(Position=2)] $filter 256 | ) 257 | 258 | if ($filter -eq $null -or $filter -eq "") 259 | { 260 | get-wmiobject -class $class -computername $sccmServer -namespace $sccmNamespace 261 | } 262 | else 263 | { 264 | get-wmiobject -query "select * from $class where $filter" -computername $sccmServer -namespace $sccmNamespace 265 | } 266 | } 267 | 268 | 269 | Function Import-SCCMDriverStore 270 | { 271 | PARAM 272 | ( 273 | [Parameter(Position=1)] $DriverStore, 274 | [Parameter(Position=3)] $CMPackageSource, 275 | #[Parameter(Position=4)] $PackageDepth, 276 | #[Parameter(Position=5)] $FolderDepth = ($packageDepth - 1), 277 | #[Parameter(Position=6)] $NameDepth = 1, 278 | [switch] $cleanup 279 | ) 280 | 281 | 282 | if ($cleanup) 283 | { 284 | $currentPrincipal = New-Object Security.Principal.WindowsPrincipal( [Security.Principal.WindowsIdentity]::GetCurrent() ) 285 | if (!$currentPrincipal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator )) 286 | { 287 | Write-Custom "You need to run Powershell as Administrator, to use the -Mirror switch." Red 288 | return; 289 | } 290 | 291 | } 292 | 293 | Write-Headline "Started Importing Driver Store: $($driverStore)" 294 | 295 | Get-ChildItem $driverStore | ? {$_.psIsContainer -eq $true} | % { 296 | 297 | $global:CurrentDepth = 1 298 | 299 | SDS-ProcessFolder $_ 300 | 301 | 302 | } 303 | 304 | } 305 | 306 | Function SDS-ProcessFolder($path) 307 | { 308 | $FolderPath = $path.FullName.Substring($DriverStore.Length+1, $path.FullName.Length-($DriverStore.Length+1)) 309 | $FolderName = $path.FullName.Substring($DriverStore.Length+1, $path.FullName.Length-($DriverStore.Length+1)) 310 | Write-Headline "Processing Folder: $($FolderName)" 311 | $CMFolderID = SDS-Folder $path 0 312 | Get-ChildItem $path.FullName | ? {$_.psIsContainer -eq $true} | % { 313 | $CurrentDepth = 2 314 | $FolderName = $_.FullName.Substring($DriverStore.Length+1, $_.FullName.Length-($DriverStore.Length+1)) 315 | Write-Headline "Processing Folder: $($FolderName)" 316 | Get-ChildItem $_.FullName | ? {$_.psIsContainer -eq $true} | % { 317 | $CurrentDepth = 3 318 | SDS-ProcessPackage $_ $FolderPath $CMFolderID 319 | } 320 | } 321 | } 322 | 323 | Function SDS-Folder($folder, $parentID) 324 | { 325 | 326 | $CMFolder = Get-SCCMObject -Class "SMS_ObjectContainerNode" -Filter "Name = `"$($folder.Name)`" AND ParentContainerNodeID = $($parentID) AND ObjectType = 23" 327 | 328 | If ($CMFolder) 329 | { 330 | $CMFolderID = $CMFolder.ContainerNodeID 331 | } 332 | Else 333 | { 334 | $CMFolderID = New-SCCMFolder -FolderName $folder.Name -FolderType 23 -ParentFolderID $parentID 335 | #Write-Custom "Created SCCM folder $($folder.Name) ($($SCCMFolderID))" 336 | } 337 | $CMFolderID 338 | } 339 | 340 | 341 | Function SDS-ProcessPackage($package, $folderPath, $folderID) 342 | { 343 | $PackageName = $package.FullName.Substring($DriverStore.Length+1, $package.FullName.Length-($DriverStore.Length+1)) 344 | 345 | #$PackageName = $PackageName.Substring($NameIndex+1, $PackageName.Length-($NameIndex+1)) 346 | $PackageName = $PackageName.Replace("\","_") 347 | 348 | Write-Headline "Processing Driver Package: $($PackageName)" 349 | $PackageHash = Get-FolderHash $package.FullName 350 | If (Get-ChildItem $package.FullName -Filter "$($PackageHash).hash") 351 | { 352 | Write-Custom "No changes has been made to this Driver Package. Skipping." DarkGray 353 | } 354 | Else 355 | { 356 | 357 | $CMCategory = Get-SCCMDriverCategory -categoryName $PackageName 358 | if ($CMCategory -eq $null) 359 | { 360 | $CMCategory = New-SCCMDriverCategory $PackageName 361 | Write-Custom "Created new driver category $($PackageName)" 362 | } 363 | 364 | 365 | $CMPackageTrue = (get-wmiobject -query "Select * from SMS_DriverPackage join SMS_ObjectContainerItem ON SMS_ObjectContainerItem.InstanceKey = SMS_DriverPackage.PackageID WHERE SMS_ObjectContainerItem.ObjectType = 23 AND SMS_ObjectContainerItem.ContainerNodeID = `"$($folderID)`" AND SMS_DriverPackage.Name = `"$($PackageName)`"" -computername $sccmServer -namespace $sccmNamespace).SMS_DriverPackage 366 | if ($CMPackageTrue -eq $null) { $CMPackageTrue = get-wmiobject -query "Select * from SMS_DriverPackage join SMS_ObjectContainerItem ON SMS_ObjectContainerItem.InstanceKey = SMS_DriverPackage.PackageID WHERE SMS_ObjectContainerItem.ObjectType = 23 AND SMS_ObjectContainerItem.ContainerNodeID = `"$($folderID)`" AND SMS_DriverPackage.Name = `"$($PackageName)`"" -computername $sccmServer -namespace $sccmNamespace } 367 | $CMPackage = get-wmiobject -query "Select * from SMS_DriverPackage WHERE SMS_DriverPackage.PackageID = `"$($CMPackageTrue.PackageID)`"" -computername $sccmServer -namespace $sccmNamespace 368 | 369 | if ($CMPackage -eq $null) 370 | { 371 | Write-Custom "Creating new driver package $($PackageName)" 372 | $CMPackageSource = "$($CMPackageSource)\$($folderPath)\$($PackageName)" 373 | #$CMPackageSource = "$($CMPackageSource)\$($PackageName)" 374 | if (Test-Path $CMPackageSource) 375 | { 376 | if((Get-Item $CMPackageSource | %{$_.GetDirectories().Count + $_.GetFiles().Count}) -gt 0) 377 | { 378 | if ($cleanup) 379 | { 380 | Write-Custom "Folder already exists, removing content" Yellow 381 | dir $driverPackageSource | remove-item -recurse -force 382 | } 383 | else 384 | { 385 | Write-Custom "Folder already exists, remove it manually." Red 386 | return 387 | } 388 | } 389 | } 390 | else 391 | { 392 | $null = MkDir $CMPackageSource 393 | } 394 | 395 | $CMPackage = New-SCCMDriverPackage -name $PackageName -sourcePath $CMPackageSource 396 | Move-SCCMObject -TargetFolderID $folderID -ObjectID $CMPackage.PackageID -ObjectType 23 397 | } 398 | else 399 | { 400 | Write-Custom "Existing driver package $($PackageName) ($($CMPackage.PackageID)) retrieved." DarkGray 401 | } 402 | 403 | #$CurrentDepth += 1 404 | 405 | #$driverPackageContent = get-wmiobject -computername $sccmServer -namespace $sccmNamespace -query "SELECT * FROM SMS_Driver WHERE CI_ID IN (SELECT CTC.CI_ID FROM SMS_CIToContent AS CTC JOIN SMS_PackageToContent AS PTC ON CTC.ContentID=PTC.ContentID JOIN SMS_DriverPackage AS Pkg ON PTC.PackageID=Pkg.PackageID WHERE Pkg.PackageID='$($CMPackage.PackageID)')" 406 | #Get-ChildItem $package.FullName -Filter *.inf -recurse | Import-SCCMDriver -category $CMCategory -package $CMPackage | % { 407 | 408 | 409 | #} 410 | 411 | Get-ChildItem $package.FullName -Filter *.inf -recurse | % { SDS-ImportDriver $_ $CMCategory $CMPackage } 412 | 413 | Get-ChildItem $package.FullName -Filter "*.hash" | Remove-Item 414 | $null = New-Item "$($package.FullName)\$($PackageHash).hash" -type file 415 | } 416 | } 417 | 418 | Function SDS-ImportDriver($dv, $category, $package) 419 | { 420 | 421 | # Split the path 422 | $driverINF = split-path $dv.FullName -leaf 423 | $driverPath = split-path $dv.FullName 424 | 425 | # Create the class objects needed 426 | $driverClass = [WmiClass]("\\$sccmServer\$($sccmNamespace):SMS_Driver") 427 | $localizedClass = [WmiClass]("\\$sccmServer\$($sccmNamespace):SMS_CI_LocalizedProperties") 428 | 429 | # Call the CreateFromINF method 430 | $driver = $null 431 | $InParams = $driverClass.psbase.GetMethodParameters("CreateFromINF") 432 | $InParams.DriverPath = $driverPath 433 | $InParams.INFFile = $driverINF 434 | try 435 | { 436 | $R = $driverClass.PSBase.InvokeMethod("CreateFromINF", $inParams, $Null) 437 | 438 | # Get the display name out of the result 439 | $driverXML = [XML]$R.Driver.SDMPackageXML 440 | $displayName = $driverXML.DesiredConfigurationDigest.Driver.Annotation.DisplayName.Text 441 | 442 | # Populate the localized settings to be used with the new driver instance 443 | $localizedSetting = $localizedClass.psbase.CreateInstance() 444 | $localizedSetting.LocaleID = 1033 445 | $localizedSetting.DisplayName = $displayName 446 | $localizedSetting.Description = "" 447 | [System.Management.ManagementObject[]] $localizedSettings += $localizedSetting 448 | 449 | # Create a new driver instance (one tied to the right namespace) and copy the needed 450 | # properties to it. 451 | $driver = $driverClass.CreateInstance() 452 | $driver.SDMPackageXML = $R.Driver.SDMPackageXML 453 | $driver.ContentSourcePath = $R.Driver.ContentSourcePath 454 | $driver.IsEnabled = $true 455 | $driver.LocalizedInformation = $localizedSettings 456 | $driver.CategoryInstance_UniqueIDs = @($category.CategoryInstance_UniqueID) 457 | 458 | # Put the driver instance 459 | $null = $driver.Put() 460 | 461 | Write-Custom "New Driver: $($displayName)" 462 | } 463 | catch [System.Management.Automation.MethodInvocationException] 464 | { 465 | $e = $_.Exception.GetBaseException() 466 | if ($e.ErrorInformation.ErrorCode -eq 183) 467 | { 468 | 469 | # Look for a match on the CI_UniqueID 470 | $query = "select * from SMS_Driver where CI_UniqueID = '" + $e.ErrorInformation.ObjectInfo + "'" 471 | $driver = get-WMIObject -query $query.Replace("\", "/") -computername $sccmServer -namespace $sccmNamespace 472 | 473 | Write-Custom "Duplicate Driver: $($driver.LocalizedDisplayName)" DarkGray 474 | 475 | # Set the category 476 | if (-not $driver) 477 | { 478 | Write-Custom "`tUnable to import and no existing driver found." Yellow 479 | return 480 | } 481 | elseif ($driver.CategoryInstance_UniqueIDs -contains $category.CategoryInstance_UniqueID) 482 | { 483 | Write-Verbose "Existing driver is already in the specified category." 484 | } 485 | else 486 | { 487 | $driver.CategoryInstance_UniqueIDs += $category.CategoryInstance_UniqueID 488 | $null = $driver.Put() 489 | Write-Verbose "Adding driver to category" 490 | } 491 | } 492 | else 493 | { 494 | Write-Custom "`tUnexpected error, skipping INF $($infFile): $($e.ErrorInformation.Description) $($e.ErrorInformation.ErrorCode)" Yellow 495 | return 496 | } 497 | } 498 | 499 | # Hack - for some reason without this we don't get the CollectionID value 500 | $hack = $driver.PSBase | select * | out-null 501 | 502 | # If a package was specified, add the driver to it 503 | if ($package -ne $null) 504 | { 505 | $driverPackageContent = get-wmiobject -computername $sccmServer -namespace $sccmNamespace -query "SELECT * FROM SMS_Driver WHERE CI_ID IN (SELECT CTC.CI_ID FROM SMS_CIToContent AS CTC JOIN SMS_PackageToContent AS PTC ON CTC.ContentID=PTC.ContentID JOIN SMS_DriverPackage AS Pkg ON PTC.PackageID=Pkg.PackageID WHERE Pkg.PackageID='$($package.PackageID)')" 506 | 507 | $doesDriverExist = $driverPackageContent | ? {$_.CI_UniqueID -eq $driver.CI_UniqueID} 508 | if ($doesDriverExist -eq $null) 509 | { 510 | # Add the driver to the package since it's not already there 511 | Write-Verbose "Adding driver to package" 512 | $null = Add-SCCMDriverPackageContent -package $package -driver $driver 513 | } 514 | 515 | } 516 | 517 | # Write the driver object to the pipeline 518 | #$driver 519 | 520 | } 521 | 522 | function Add-SCCMDriverPackageContent 523 | { 524 | [CmdletBinding()] 525 | PARAM 526 | ( 527 | [Parameter(Position=1)] $package, 528 | [Parameter(Position=2, ValueFromPipeline=$true)] $driver 529 | ) 530 | 531 | Process 532 | { 533 | # Get the list of content IDs 534 | $idlist = @() 535 | $ci = $driver.CI_ID 536 | 537 | $i = 1 538 | $ids = Get-SCCMObject -class SMS_CIToContent -filter "CI_ID = '$ci'" 539 | 540 | if ($ids -eq $null) 541 | { 542 | Write-Warning "Warning: Driver not found in SMS_CIToContent" 543 | } 544 | foreach ($id in $ids) 545 | { 546 | $idlist += $id.ContentID 547 | } 548 | 549 | # Build a list of content source paths (one entry in the array) 550 | $sources = @($driver.ContentSourcePath) 551 | 552 | # Invoke the method 553 | try 554 | { 555 | $package.AddDriverContent($idlist, $sources, $false) 556 | } 557 | catch [System.Management.Automation.MethodInvocationException] 558 | { 559 | $e = $_.Exception.GetBaseException() 560 | if ($e.ErrorInformation.ErrorCode -eq 1078462229) 561 | { 562 | Write-Verbose "Driver is already in the driver package (possibly because there are multiple INFs in the same folder or the driver already was added from a different location): $($e.ErrorInformation.Description)" 563 | } 564 | } 565 | } 566 | 567 | } 568 | 569 | 570 | 571 | New-SCCMConnection "CM01" "sitecode" 572 | Import-SCCMDriverStore "\\CM01\sccm_store\OSD\DriverSources" "\\CM01\sccm_store\OSD\DriverPackages" 573 | -------------------------------------------------------------------------------- /Install-Fonts.ps1: -------------------------------------------------------------------------------- 1 | #Font Locations 2 | #Network Location 3 | $NetworkPath = "\\cm01\Fonts" 4 | #Local Location (temp place to store fonts) 5 | $LocalPath= "C:\Users\Public\Fonts\" 6 | 7 | $FONTS = 0x14 8 | $objShell = New-Object -ComObject Shell.Application 9 | $objFolder = $objShell.Namespace($FONTS) 10 | 11 | New-Item $LocalPath -type directory -Force 12 | Copy-Item "$NetworkPath\*" $LocalPath 13 | 14 | $Fontdir = dir $LocalPath 15 | foreach($File in $Fontdir) 16 | { 17 | if ((Test-Path "C:\Windows\Fonts\$File") -eq $False) 18 | { 19 | $objFolder.CopyHere($File.fullname,0x10) 20 | } 21 | } -------------------------------------------------------------------------------- /InstallConfigMgrPreReq1.4.1.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thestardawg/ConfigMgr/7f195f7eecc918b466b8a560ab6fb8e092f62f31/InstallConfigMgrPreReq1.4.1.ps1 -------------------------------------------------------------------------------- /InstallDriverWinPE.ps1: -------------------------------------------------------------------------------- 1 | #For those computers you are trying to image, that simply reboot before they let you select a task sequence, because they don't have the right nic driver in the boot image.... 2 | #Put the folders of potential drivers on a flash drive (F:\ in the script). Run this PS code: 3 | 4 | $driverpaths = get-childitem "F:\" -recurse | where {$_.extension -eq ".inf"} 5 | foreach ($driver in $driverpaths){ 6 | $fullpath = $driver.FullName 7 | "drvload $fullpath" | out-file F:\installdrivers.bat -Encoding ascii -append 8 | "ipconfig" | out-file F:\installdrivers.bat -Encoding ascii -append 9 | "pause" | out-file F:\installdrivers.bat -Encoding ascii -append 10 | } -------------------------------------------------------------------------------- /LaunchICEasAdmin.ps1: -------------------------------------------------------------------------------- 1 | Start-Process powershell.exe -Credential "domain\name" -NoNewWindow -ArgumentList "Start-Process powershell_ise.exe -Verb runAs" -------------------------------------------------------------------------------- /LaunchPSasAdmin.ps1: -------------------------------------------------------------------------------- 1 | Start-Process powershell.exe -Credential "domain\name" -NoNewWindow -ArgumentList "Start-Process powershell.exe -Verb runAs" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ConfigMgr -------------------------------------------------------------------------------- /Refresh-DP_Missing_Content.ps1: -------------------------------------------------------------------------------- 1 | #Load Configuration Manager PowerShell Module 2 | Import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1') 3 | 4 | #Get SiteCode 5 | $SiteCode = Get-PSDrive -PSProvider CMSITE 6 | Set-location $SiteCode":" 7 | 8 | $failures = $null 9 | 10 | # Find all content with State = 1, State = 2 or State = 3, see http://msdn.microsoft.com/en-us/library/cc143014.aspx 11 | $failures = Get-WmiObject -Namespace root\sms\site_$SiteCode -Query "SELECT * FROM SMS_PackageStatusDistPointsSummarizer WHERE State = 1 or State = 2 Or state = 3 Or state = 8" 12 | 13 | 14 | if ($failures -eq $null) 15 | { 16 | "No failed content distribution." 17 | } 18 | else 19 | { 20 | foreach ($failure in $failures) 21 | { 22 | # Get the distribution points that content wouldn't distribute to 23 | $DistributionPoints = Get-WmiObject -Namespace root\sms\site_$SiteCode -Query "SELECT * FROM SMS_DistributionPoint WHERE SiteCode='$($failure.SiteCode)' AND PackageID='$($failure.PackageID)'" 24 | foreach ($DistributionPoint in $DistributionPoints) 25 | { 26 | #check if we are really looking at the correct Distribution Point 27 | if ($DistributionPoint.ServerNALPath -eq $failure.ServerNALPath) 28 | { 29 | # Use the RefreshNow Property to "Refresh Distribution Point", see http://msdn.microsoft.com/en-us/library/hh949735.aspx 30 | $DistributionPoint.RefreshNow = $true 31 | $DistributionPoint.put() 32 | 33 | } 34 | 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /RefreshPackageonAllDPs.ps1: -------------------------------------------------------------------------------- 1 | $SiteCode = "" 2 | $PackageID = "" 3 | $distpoints = Get-WmiObject -Namespace "root\SMS\Site_$($SiteCode)" -Query "Select * From SMS_DistributionPoint WHERE PackageID='$PackageID'" 4 | foreach ($dp in $distpoints) 5 | { 6 | $dp.RefreshNow = $true 7 | $dp.Put() 8 | } 9 | -------------------------------------------------------------------------------- /RefreshPackageonSingleDP.ps1: -------------------------------------------------------------------------------- 1 | #Load Configuration Manager PowerShell Module 2 | Import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1') 3 | 4 | $SiteCode = "TAB" 5 | 6 | $PackageID = "TAB00004" 7 | 8 | $nalpath = '["Display=\\1ndcitvwmp01.tsi.lan\"]MSWNET:["SMS_SITE=TSP"]\\tri-sccmsql.twi.dom\' 9 | 10 | $distpoint = Get-WmiObject -class SMS_DistributionPoint -namespace "root\SMS\Site_$($SiteCode)" | Where-Object{$_.PackageID -match "$PackageID"} 11 | 12 | 13 | foreach($dp in $distpoint) 14 | { 15 | 16 | If($nalpath -eq $dp.ServerNalPath) 17 | { 18 | $dp.RefreshNow = $true 19 | $dp.Put() 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /RemoveMBAMRegEntries.reg: -------------------------------------------------------------------------------- 1 | Windows Registry Editor Version 5.00 2 | 3 | [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MBAM] 4 | "KeyRecoveryOptions"=- 5 | "UseKeyRecoveryService"=- 6 | "KeyRecoveryServiceEndPoint"=- 7 | "DeploymentTime"=- 8 | "NoStartupDelay"=- -------------------------------------------------------------------------------- /Restart-WDS.ps1: -------------------------------------------------------------------------------- 1 | Invoke-Command -ComputerName DP01 {Restart-Service WDSServer} -------------------------------------------------------------------------------- /Schedule_Distribution_of_all_applications_to_DP_Group.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Distributes all Applications created within a certain time frame to a Distribution Point Group 4 | .DESCRIPTION 5 | Distributes all Applications created within a certain time frame to a Distribution Point Group 6 | .PARAMETER SiteServer 7 | Primary Site server name 8 | .PARAMETER DPGName 9 | Specify a Distribution Point Group name 10 | .PARAMETER CreatedDaysAgo 11 | Specify the amount of days ago an Application was created. The script will only enumerate Applications created within the specified time frame. 12 | .EXAMPLE 13 | Start to distribute all Applications created within the last day to a Distribution Point Group called 'All DPs' on a Site server called 'CM01': 14 | 15 | .\Start-ApplicationDistribution.ps1 -SiteServer "CM01" -DPGName "All DPs" 16 | .EXAMPLE 17 | Start to distribute all Applications created within the last 3 days to a Distribution Point Group called 'All DPs' on a Site server called 'CM01': 18 | 19 | .\Start-ApplicationDistribution.ps1 -SiteServer "CM01" -DPGName "All DPs" -CreatedDaysAgo 3 20 | .NOTES 21 | Script name: Start-ApplicationDistribution.ps1 22 | Author: Nickolaj Andersen 23 | Contact: @NickolajA 24 | DateCreated: 2014-09-22 25 | #> 26 | [CmdletBinding(SupportsShouldProcess=$true)] 27 | param( 28 | [parameter(Mandatory=$true, HelpMessage="Specify the Primary Site server")] 29 | [ValidateScript({Test-Connection -ComputerName $_ -Count 2})] 30 | [string]$SiteServer = "$($env:COMPUTERNAME)", 31 | [parameter(Mandatory=$true, HelpMessage="Specify the name of a Distribution Point Group")] 32 | [string]$DPGName, 33 | [parameter(Mandatory=$false, HelpMessage="Specify the name of a Distribution Point Group")] 34 | [int]$CreatedDaysAgo = 1 35 | ) 36 | Begin { 37 | # Determine SiteCode from WMI 38 | try { 39 | Write-Verbose "Determining SiteCode for Site Server: '$($SiteServer)'" 40 | $SiteCodeObjects = Get-WmiObject -Namespace "root\SMS" -Class SMS_ProviderLocation -ComputerName $SiteServer -ErrorAction Stop 41 | foreach ($SiteCodeObject in $SiteCodeObjects) { 42 | if ($SiteCodeObject.ProviderForLocalSite -eq $true) { 43 | $SiteCode = $SiteCodeObject.SiteCode 44 | Write-Debug "SiteCode: $($SiteCode)" 45 | } 46 | } 47 | } 48 | catch [Exception] { 49 | Throw "Unable to determine SiteCode" 50 | } 51 | # Load the Configuration Manager 2012 PowerShell module 52 | try { 53 | Write-Verbose "Importing Configuration Manager module" 54 | Write-Debug ((($env:SMS_ADMIN_UI_PATH).Substring(0,$env:SMS_ADMIN_UI_PATH.Length-5)) + "\ConfigurationManager.psd1") 55 | Import-Module ((($env:SMS_ADMIN_UI_PATH).Substring(0,$env:SMS_ADMIN_UI_PATH.Length-5)) + "\ConfigurationManager.psd1") -Force -ErrorAction Stop 56 | if ((Get-PSDrive $SiteCode -ErrorAction SilentlyContinue | Measure-Object).Count -ne 1) { 57 | New-PSDrive -Name $SiteCode -PSProvider "AdminUI.PS.Provider\CMSite" -Root $SiteServer -ErrorAction Stop 58 | } 59 | # Set the location to the Configuration Manager drive 60 | Set-Location ($SiteCode + ":") 61 | } 62 | catch [Exception] { 63 | Throw $_.Exception.Message 64 | } 65 | } 66 | Process { 67 | # Validate specified Distribution Point Group 68 | try { 69 | $DPG = Get-WmiObject -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_DistributionPointGroup -ComputerName $SiteServer -Filter "Name = '$($DPGName)'" 70 | if (($DPG | Measure-Object).Count -eq 1) { 71 | Write-Verbose "Found Distribution Point Group: $($DPG.Name)" 72 | } 73 | elseif (($DPG | Measure-Object).Count -gt 1) { 74 | Throw "Query for DPGs returned more than 1 object" 75 | } 76 | else { 77 | Throw "Unable to determine Distribution Point Group name from specified string for parameter 'DPGName'" 78 | } 79 | } 80 | catch [Exception] { 81 | Throw $_.Exception.Message 82 | } 83 | # Start Application distribution 84 | try { 85 | Write-Verbose "Enumerating applicable Applications" 86 | $Applications = Get-CMApplication | Select-Object LocalizedDisplayName, PackageID, DateCreated | Where-Object { $_.DateCreated -ge (Get-Date).AddDays(-$CreatedDaysAgo) } 87 | foreach ($Application in $Applications) { 88 | if (-not(Get-WmiObject -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_DPGroupDistributionStatusDetails -ComputerName $SiteServer -Filter "PackageID = '$($Application.PackageID)'" -ErrorAction SilentlyContinue)) { 89 | if ($PSCmdlet.ShouldProcess("$($DPG.Name)", "Distribute Application: $($Application.LocalizedDisplayName)")) { 90 | $DPG.AddPackages($Application.PackageID) | Out-Null 91 | } 92 | } 93 | } 94 | Set-Location C: 95 | } 96 | catch [Exception] { 97 | Throw $_.Exception.Message 98 | } 99 | } -------------------------------------------------------------------------------- /SecurePWChangeAcrossWholeENV.ps1: -------------------------------------------------------------------------------- 1 | #first part 2 | $computer = $env:COMPUTERNAME 3 | $pass = "NewPass09" 4 | $user = "ITSupportAcct" 5 | $newpass = [ADSI]"WinNT://$computer/$user,user" 6 | $newpass.SetPassword($pass) 7 | $newpass.SetInfo() 8 | #second part encrpt input 9 | param($key) 10 | $key = @($key.split(",")) 11 | $raw = Get-content .\Encrypted.bin 12 | $secure = ConvertTo-SecureString $raw -key $key 13 | $helper = New-Object System.Management.Automation.PSCredential("Temp",$secure) 14 | $plain = $helper.GetNetworkCredential().Password 15 | Invoke-Expression $plain 16 | #thirdpart decrypt 17 | param($decrypted,$encrypted) 18 | 19 | $key = (1,0,5,9,56,34,254,211,4,4,2,23,42,54,33,200,1,34,2,7,6,9,35,37) 20 | $script = Get-Content $decrypted | Out-String 21 | $secure = ConvertTo-SecureString $script -asPlainText -force 22 | $export = $secure | ConvertFrom-SecureString -key $key 23 | Set-Content $encrypted $export 24 | "Script '$decrypted' has been encrypted as '$encrypted'" 25 | #commandline generate 26 | # powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File Decrypt.ps1 1,0,5,9,56,34,254,211,4,4,2,23,42,54,33,200,1,34,2,7,6,9,35,37 27 | -------------------------------------------------------------------------------- /SetTPMPolicy.wsf: -------------------------------------------------------------------------------- 1 | 2 | 91 | 92 | -------------------------------------------------------------------------------- /StartMBAMEncryption.wsf: -------------------------------------------------------------------------------- 1 | 2 | 493 | 494 | -------------------------------------------------------------------------------- /StartMBAMEncryptionReg.wsf: -------------------------------------------------------------------------------- 1 | 2 | 148 | 149 | -------------------------------------------------------------------------------- /deletecomputer.ps1: -------------------------------------------------------------------------------- 1 | $compName = "IT-HyperT39" 2 | 3 | Import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1') 4 | Import-Module ActiveDirectory -Function Remove-ADObject 5 | 6 | try { 7 | Write-Output "Searching for AD Computer $compname" 8 | $comp = Get-AdComputer $compName -ErrorAction Continue 9 | } 10 | catch { 11 | Write-Output "AD Computer $compName was not found" 12 | $comp = $null 13 | } 14 | 15 | if ($comp.DistinguishedName -ne $null) { 16 | Write-Output "Removing AD Computer $compName" 17 | $comp.DistinguishedName | Remove-ADObject -Recursive -Confirm:$false 18 | Write-Output "AD Computer $compName was removed" 19 | } else { 20 | } 21 | 22 | try { 23 | Write-Output "Removing SCCM Computer $compName" 24 | $PSD = Get-PSDrive -PSProvider CMSITE 25 | Set-Location "$($PSD):" 26 | Remove-CMDevice -Name $compName -Confirm:$false -Force -ErrorAction Stop 27 | Write-Output "SCCM Computer $compName was removed" 28 | } 29 | catch { 30 | Write-Output "SCCM Computer $compName was not found" 31 | } 32 | Set-Location "C:" -------------------------------------------------------------------------------- /discoveryitem-lms.ps1: -------------------------------------------------------------------------------- 1 | #SCCM CB ConfigItem / Remediation to turn LMS off and disable from auto startup. 2 | 3 | #Discovery - Script - String. 4 | (get-wmiobject -namespace root\CIMv2 -class Win32_Service | where-object -filterscript {$_.Name -eq “LMS”}).started 5 | 6 | #Remediation 7 | $service = get-wmiobject -namespace root\cimv2 -class Win32_Service | where-object -filterscript {$_.Name -eq “lms”} 8 | $service.changestartmode(“disabled”) 9 | $service.stopservice() 10 | 11 | #Compliance Rule 12 | #Condition = False. Remediation = Yes. --------------------------------------------------------------------------------