├── Backup and Compression ├── 7za.exe.stub ├── Backup-ToWIM.7Zini ├── Backup-ToWIM.cmd ├── Backup-ToWIM.ini ├── Backup-ToWIM.vbs ├── Compress-ArchiveZPAQ.ps1 ├── gImagex.exe.stub ├── imagex.exe.stub └── zPaq64.exe.stub ├── ConfigMgr ├── Connect-ConfigMgr.ps1 ├── Document │ ├── Get-MCMActiveDeployments.sql │ ├── Get-MCMAdminConsoleUsers.ps1 │ ├── Get-MCMDeviceCollectionPrimaryEmailAddresses.ps1 │ ├── Get-MCMDistributionPointDetails.ps1 │ ├── Get-MCMInfo.cmd │ ├── Get-MCMPackageSize.ps1 │ ├── Get-MCMPackageSizeForAllTypes.ps1 │ ├── Get-MCMPackagesConfiguredForPackageShares.ps1 │ ├── Get-MCMSiteInfo.ps1 │ ├── Get-MCMSoftwareUpdatePackageSize.ps1 │ └── get-MCMDPRateLimits.ps1 ├── EventDriven Scripts │ ├── New-SSRS_EmailSubscription_Compliance_1_-_Overall compliance.ps1 │ ├── New-SSRS_EmailSubscription_States 4 - Computers in specific states for a deployment (custom).ps1 │ └── New-SSRS_Subscription_FromCMEvent.ps1 ├── Exported Objects │ ├── Collections │ │ └── Collections.mof │ └── Queries │ │ └── Common Queries.mof ├── Global Conditions │ └── Get-ChassisTypeName.vbs ├── Install and Configure │ ├── Copy-MCMDistributionPointContent.ps1 │ ├── Set-DataDeduplication.ps1 │ ├── Set-MCMDistributionPointRateLimits.ps1 │ └── Start-DataDeduplication.ps1 ├── Migrate, Export and Import │ ├── Export-MCMApplications.ps1 │ ├── Export-MCMIconsFromDatabase.ps1 │ ├── Export-MCMObjects.ps1 │ └── See new repo just for this!.txt ├── OSD Server Logs │ └── CopyLogs.cmd ├── OSD WinPE Extra Files │ └── x64 │ │ ├── Copy-Logs.cmd │ │ ├── Tools │ │ ├── 7-Zip │ │ │ └── 7-zip File Manager and Extra files.stub │ │ ├── AddMeToCollection.vbs │ │ ├── Remove-LockScreen.ps1 │ │ ├── ServiceUI.exe.stub │ │ ├── Set-ImageInfo-Deploy.vbs │ │ ├── Set-LockScreen.ps1 │ │ ├── Set-OEMInfo.vbs │ │ ├── Set-OSDComputerNamePrompt.ps1 │ │ ├── Set-WinPEWallpaper.ps1 │ │ ├── SetupWinPEBoot.ps1 │ │ ├── Start-VNC.cmd │ │ ├── Teardown.ps1 │ │ ├── Test-PendingReboot.ps1 │ │ ├── Test-Port.ps1 │ │ ├── TsProgressUI.exe.stub │ │ ├── Write-TSVariables.ps1.stub │ │ ├── ZTIUtility.vbs │ │ ├── config.xml │ │ └── devcon.exe.stub │ │ └── Windows │ │ ├── 7za.exe.stub │ │ ├── Clean-Disk0.cmd │ │ ├── Enable-RemoteSupport.cmd │ │ ├── Get-ComputerName.cmd │ │ ├── Get-SMSTSLog.cmd │ │ ├── Get-ScreenShot.cmd │ │ ├── Get-TSVars.cmd │ │ ├── SMSTS.ini │ │ └── Set-OneNICActive.cmd ├── Operations │ ├── Add-MCMComputersFromOneCollectionToAnother.ps1 │ ├── Add-MCMUpdateToPackage.ps1 │ ├── Cancel-MCMPendingReboot.ps1 │ ├── Collection Management │ │ ├── Advanced Collection Viewer.ps1 │ │ └── Clear-CollectionMembership.ps1 │ ├── ConfigMgr GPO examples │ │ ├── ConfigMgr GPOs │ │ │ ├── Install ConfigMgr Client.html │ │ │ ├── Manage BITS on WinXP_2003.html │ │ │ ├── Manage BITS.html │ │ │ ├── Manage ConfigMgr Client.html │ │ │ ├── Manage Win10 Delivery Optimization.html │ │ │ ├── Manage WinRM.html │ │ │ ├── Manage Windows Update Agent.html │ │ │ ├── {349C7B9E-6740-4519-B65E-F6D9BC8EC8AF} │ │ │ │ ├── Backup.xml │ │ │ │ ├── DomainSysvol │ │ │ │ │ └── GPO │ │ │ │ │ │ ├── Adm │ │ │ │ │ │ ├── configmgrassignment.adm │ │ │ │ │ │ └── configmgrinstallation.adm │ │ │ │ │ │ └── Machine │ │ │ │ │ │ ├── Applications │ │ │ │ │ │ └── {2BDD37FE-E5E6-48F1-98E3-75EA91C7AFD9}.aas │ │ │ │ │ │ └── registry.pol │ │ │ │ ├── bkupInfo.xml │ │ │ │ └── gpreport.xml │ │ │ ├── {4B518C3A-10E9-4CF2-995E-9273B182D86F} │ │ │ │ ├── Backup.xml │ │ │ │ ├── DomainSysvol │ │ │ │ │ └── GPO │ │ │ │ │ │ └── Machine │ │ │ │ │ │ ├── comment.cmtx │ │ │ │ │ │ ├── microsoft │ │ │ │ │ │ └── windows nt │ │ │ │ │ │ │ └── SecEdit │ │ │ │ │ │ │ └── GptTmpl.inf │ │ │ │ │ │ └── registry.pol │ │ │ │ ├── bkupInfo.xml │ │ │ │ └── gpreport.xml │ │ │ ├── {5D14D390-ACB2-41B6-85DA-2E8C56203BDC} │ │ │ │ ├── Backup.xml │ │ │ │ ├── DomainSysvol │ │ │ │ │ └── GPO │ │ │ │ │ │ └── Machine │ │ │ │ │ │ ├── comment.cmtx │ │ │ │ │ │ ├── microsoft │ │ │ │ │ │ └── windows nt │ │ │ │ │ │ │ └── SecEdit │ │ │ │ │ │ │ └── GptTmpl.inf │ │ │ │ │ │ └── registry.pol │ │ │ │ ├── bkupInfo.xml │ │ │ │ └── gpreport.xml │ │ │ ├── {74917769-439E-4C57-9872-EDA53C9ECA9D} │ │ │ │ ├── Backup.xml │ │ │ │ ├── DomainSysvol │ │ │ │ │ └── GPO │ │ │ │ │ │ └── Machine │ │ │ │ │ │ ├── Preferences │ │ │ │ │ │ ├── Files │ │ │ │ │ │ │ └── Files.xml │ │ │ │ │ │ ├── Folders │ │ │ │ │ │ │ └── Folders.xml │ │ │ │ │ │ └── ScheduledTasks │ │ │ │ │ │ │ └── ScheduledTasks.xml │ │ │ │ │ │ ├── Scripts │ │ │ │ │ │ └── scripts.ini │ │ │ │ │ │ ├── microsoft │ │ │ │ │ │ └── windows nt │ │ │ │ │ │ │ └── SecEdit │ │ │ │ │ │ │ └── GptTmpl.inf │ │ │ │ │ │ └── registry.pol │ │ │ │ ├── bkupInfo.xml │ │ │ │ └── gpreport.xml │ │ │ ├── {ACA769E3-6C81-414A-B71B-8136A4A22311} │ │ │ │ ├── Backup.xml │ │ │ │ ├── DomainSysvol │ │ │ │ │ └── GPO │ │ │ │ │ │ └── Machine │ │ │ │ │ │ ├── comment.cmtx │ │ │ │ │ │ ├── microsoft │ │ │ │ │ │ └── windows nt │ │ │ │ │ │ │ └── SecEdit │ │ │ │ │ │ │ └── GptTmpl.inf │ │ │ │ │ │ └── registry.pol │ │ │ │ ├── bkupInfo.xml │ │ │ │ └── gpreport.xml │ │ │ ├── {D7A8AF60-1697-4155-8CAC-A91DF02120D6} │ │ │ │ ├── Backup.xml │ │ │ │ ├── DomainSysvol │ │ │ │ │ └── GPO │ │ │ │ │ │ └── Machine │ │ │ │ │ │ ├── Microsoft │ │ │ │ │ │ └── Windows NT │ │ │ │ │ │ │ └── SecEdit │ │ │ │ │ │ │ └── GptTmpl.inf │ │ │ │ │ │ ├── comment.cmtx │ │ │ │ │ │ └── registry.pol │ │ │ │ ├── bkupInfo.xml │ │ │ │ └── gpreport.xml │ │ │ └── {ECFF29C7-53CD-4E92-AC67-8CEB50621CC1} │ │ │ │ ├── Backup.xml │ │ │ │ ├── DomainSysvol │ │ │ │ └── GPO │ │ │ │ │ └── Machine │ │ │ │ │ ├── comment.cmtx │ │ │ │ │ ├── microsoft │ │ │ │ │ └── windows nt │ │ │ │ │ │ └── SecEdit │ │ │ │ │ │ └── GptTmpl.inf │ │ │ │ │ └── registry.pol │ │ │ │ ├── bkupInfo.xml │ │ │ │ └── gpreport.xml │ │ └── Netlogon │ │ │ ├── CCMSetup │ │ │ └── ccmsetup.msi.stub │ │ │ └── CCMtools │ │ │ ├── ConfigMgrClientHealth.ps1 │ │ │ ├── ConfigMgrStartup-WMI.xml │ │ │ ├── ConfigMgrStartup.custom.xml │ │ │ ├── ConfigMgrStartup.xml │ │ │ ├── ConfigMgrStartup1.75.vbs │ │ │ └── config.xml │ ├── Copy-MCMContentFromDPtoDPGroup.ps1 │ ├── Get-MCMDistributionPointDetails.ps1 │ ├── Invoke-MCMHardwareInventory.ps1 │ ├── Remove-MCMDistributionPointContent.ps1 │ ├── Set-MCMDistributionPoint_DistributeOnDemand.ps1 │ ├── Status Message Filer Rule Scripts │ │ ├── Command-Line Parameters for Status Filter Rules.txt │ │ ├── Get-MCMStatusMessageStrings.ps1 │ │ └── Write-StatusMessageLog.cmd │ ├── Update-MCMObjectSecurityScopes.ps1 │ └── Variables (Machine and Collection) │ │ └── Set-MCMMachineVariables.ps1 ├── Reports │ └── Compliance 5 - Computers in a Collection.rdl ├── Scheduled Scripts │ ├── Export-MCMCollectionMemberInfo.ps1 │ ├── Set-MCMSecurityScopes_byFolder.ps1 │ └── Set-MCMSoftwareUpdateMaximumExecutionTime.ps1 ├── Software Deployment │ └── Start-MCMPackageDeployment.ps1 ├── Software Updates │ ├── Invoke-DGASoftwareUpdateMaintenance │ │ └── config.ini │ └── Rename-MCMSoftwareUpdateGroupDeployments.ps1 ├── Task Sequences │ ├── Copy-LogsToArchive.ps1 │ ├── Invoke-TS_Finalize.ps1 │ ├── Invoke-TS_Functions.ps1 │ ├── Invoke-TS_Initialize.ps1 │ ├── Invoke-TS_LogParser.ps1 │ ├── Write-TSVariables.ps1 │ └── ZTIUtility.vbs └── Troubleshooting │ ├── Remove-MCMClient.ps1 │ ├── Remove-MCMClientGUID.ps1 │ ├── Repair-MCMClient.ps1 │ └── Reset-MCMClientPolicy.ps1 ├── InstallTemplate-Batch-Simple.cmd ├── InstallTemplate-Batch.cmd ├── Intune ├── Export-IntuneDeviceConfigurations.ps1 ├── Export-M365Configurations.ps1 ├── Import-IntuneDeviceConfigurationFromJSON.ps1 └── Test-PowerShell_via_Intune.ps1 ├── Microsoft Updates ├── Install-MSUpdate.cmd ├── Install-MSUpdates.cmd ├── Install-MicrosoftUpdatesPSADT │ ├── AppDeployToolkit.url │ ├── AppDeployToolkit │ │ └── AppDeployToolkitExtensions.ps1 │ ├── Install-MicrosoftUpdates.ps1 │ └── readme.md ├── README.md ├── Remove-HotfixesInstalledInLast1Day.ps1 ├── Remove-MicrosoftUpdate.ps1 ├── Remove-MicrosoftUpdateEx.ps1 └── Set-QualityCompatRegKey.ps1 ├── Misc ├── Click-ButtonContinuously.au3 ├── Create-RandomFiles.ps1 ├── Functions-FileSigTimestamp.ps1 ├── Get-OneDriveKFM_Status.ps1 ├── Move-FilesByNameDate.ps1 ├── New-LocalUserAsAdmin.ps1 ├── Out-GridView_IISLog.ps1 └── Test-EncodeDecodeInBase64.ps1 ├── New-Script.cmd ├── New-Script.ps1 ├── New-Script.vbs ├── PowerShell ├── Microsoft.PowerShellISE_profile.ps1 └── Microsoft.PowerShell_profile.ps1 ├── README.md ├── Upgrade-Windows ├── AppDeployToolkit.stub ├── Deploy-Application.ps1 ├── Update-WindowsImageViaServicing.ps1 ├── Upgrade-Windows.cmd └── Upgrade-Windows.ps1 ├── WSUS └── Set-WSUSandIISsettings.ps1 ├── Windows Drivers ├── Extract-Drivers.cmd ├── Remove-DellTouchpad │ ├── Remove-DellTouchPad.cmd │ └── devcon.exe.stub ├── Stage-Drivers.cmd ├── Update-DellDriversFromInternet.cmd ├── Update-Drivers.cmd ├── Update-Drivers.ps1 └── Update-WindowsDriversFromMicrosoftUpdate.ps1 ├── Windows Installer ├── CSI_ExtractMSIGUIDAndIcons.TXT ├── CSI_ExtractMSIGUIDAndIcons.vbs ├── Get-MSIFileInformation.ps1 ├── Get-MSIFileInformationEx.ps1 ├── Get-MSIdetails.vbs ├── Get-MSIinstalls.vbs └── Get-MSUFileInfo_Function.ps1 ├── Windows ├── Clean-SystemDiskSpace.ps1 ├── Get-InstalledAppsViaRegistry.ps1 ├── Get-ShareAndFolderPermissions.ps1 ├── Get-Uptime.ps1 ├── Reset-WindowsUpdateAgent.ps1 ├── Set mobile network connections as non-metered by default.zip ├── Set-TimeSyncOnWorkgroupComputer.cmd ├── Set-WindowsNetworkConnectionsAsNonMetered.ps1 ├── Test-PendingRestart.ps1 ├── Test-SecureBootBlackLotusMitigation.ps1 └── Update-MicrosoftStoreApps.ps1 └── _config.yml /Backup and Compression/7za.exe.stub: -------------------------------------------------------------------------------- 1 | Stub file to be replaced by the actual file from https://7-zip.org/a/7z2301-extra.7z -------------------------------------------------------------------------------- /Backup and Compression/Backup-ToWIM.7Zini: -------------------------------------------------------------------------------- 1 | *.exe 2 | ~*.* 3 | *.tmp 4 | *.lock 5 | thumbs.db 6 | winpepge.sys 7 | UserMan.ini 8 | LLU_Admin.Local.db 9 | LLU_Admin.Network.db 10 | pagefile.sys 11 | hiberfil.sys 12 | $ntfs.log 13 | GDIPFONTCACHEV1.DAT 14 | "Temporary Internet Files" 15 | Temp 16 | MININT 17 | RECYCLE.BIN 18 | $RECYCLE.BIN 19 | RECYCLER 20 | Windows.old 21 | Windows\Logs 22 | Windows\CSC 23 | Windows\Panther 24 | Windows\SoftwareDistribution 25 | _SMSTaskSequence 26 | "System Volume Information" 27 | inetpub\logs\*.log -------------------------------------------------------------------------------- /Backup and Compression/Backup-ToWIM.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | set AppTitle=Backup To WIM 4 | 5 | Call:Get-CommonCommandLineOptions %* 6 | If NOT [%doHelp%]==[True] goto:Begin 7 | echo =============================================================================== 8 | echo .Synopsis 9 | echo Install %AppTitle% 10 | echo .Description 11 | echo Backup Drive/Folder to WIM keeping multiple backups 12 | echo .Functionality 13 | echo Software installation and configuration 14 | echo .Parameter 1 15 | echo BackupType [WIM|7z|ALL] 16 | echo .Parameter 2 17 | echo BackupName - Creates a WIM file with this name 18 | ::TODO:: echo .Parameter 3 19 | ::TODO:: echo SourceDir - Root folder to backup 20 | ::TODO:: echo .Parameter 4 21 | ::TODO:: echo TargetDir - Folder to create the WIM file in 22 | ::TODO:: echo .Parameter 23 | ::TODO:: echo [/h] [/help] display this help information 24 | echo .Example 25 | echo Backup-ToWIM.cmd WIM USB_SecurityTools 26 | echo .Example 27 | echo Backup-ToWIM.cmd ALL USB_SecurityTools 28 | echo .Notes 29 | echo === References and Sources === 30 | echo ??? 31 | echo === Change Log History === 32 | echo YYYY/MM/DD by Chad@ChadsTech.net - updated ??? 33 | echo YYYY/MM/DD by Chad@ChadsTech.net - Created 34 | echo ================================================================================ 35 | goto:eof 36 | 37 | 38 | if NOT [%1]==[] set /p SourceDir=%~dp0 39 | if NOT [%2]==[] set /p BackupName=Backup Name 40 | 41 | echo SourceDir is %SourceDir% 42 | echo BackupName is %BackupName% 43 | exit /b 44 | 45 | set SourceDir=%~dp0 46 | set TargetDir=B:\Backup\ 47 | Set TargetDir=%TargetDir:~,-1% 48 | ::folder for 2nd backup location. comment out to skip 49 | ::Set BackupDir=A:\Backup\ 50 | 51 | echo Backuping '%BackupName%' 52 | echo Source location '%SourceDir%' 53 | echo Destination location '%TargetDir%' 54 | if Defined BackupDir echo 2nd Backup location '%BackupDir%' 55 | 56 | 57 | ::set the default backup type to WIM only, overwrite via the command line 58 | Set BackupTypes=WIM 59 | If NOT "%1"=="" Set BackupTypes=%1 60 | 61 | Call:GetDates 62 | if %BackupTypes%==WIM Call:Backup-WIM 63 | if %BackupTypes%==7z Call:Backup-7z 64 | if %BackupTypes%==all Call:Backup-WIM 65 | if %BackupTypes%==all Call:Backup-7z 66 | endlocal 67 | goto:eof 68 | 69 | :GetDates 70 | ::http://stackoverflow.com/questions/203090/how-to-get-current-datetime-on-windows-command-line-in-a-suitable-format-for-us 71 | for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j 72 | set YYYYMMDD_HHMM=%ldt:~0,8%_%ldt:~8,4% 73 | set YYYYMMDD=%ldt:~0,8% 74 | set YYYY=%ldt:~0,4% 75 | set MM=%ldt:~4,2% 76 | set DD=%ldt:~6,2% 77 | set hh=%ldt:~8,2% 78 | set nn=%ldt:~10,2% 79 | set ss=%ldt:~12,2% 80 | echo the date and time is %YYYYMMDD_HHMM% 81 | goto:eof 82 | 83 | :Backup-7z 84 | echo compress with 7-zip command line 85 | If Exist "%TargetDir%\7za.exe" Set Tool="%TargetDir%\7za.exe" 86 | If Exist "%~dp07za.exe" Set Tool="%~dp07za.exe" 87 | %Tool% a -mx4 -t7z -r -xr!*.tmp -xr!thumbs.db "%TargetDir%\%BackupName%-%yyyy%-%mm%-%dd%.7z" "%SourceDir%\*.*" 88 | Call:MakeCopy *.7z 89 | goto:eof 90 | 91 | :Backup-WIM 92 | If Exist "%TargetDir%\Backup-ToWIM.ini" Set ExcFile=%TargetDir%\Backup-ToWIM.ini 93 | If Exist "%~dp0Backup-ToWIM.ini" Set ExcFile=%~dp0Backup-ToWIM.ini 94 | If Exist "%TargetDir%\%BackupName%.ini" Set ExcFile=%TargetDir%\%BackupName%.ini 95 | If Exist "%~dp0%BackupName%.ini" Set ExcFile=%~dp0%BackupName%.ini 96 | 97 | echo compress with ImageX (if available) or DISM command line 98 | set method=CAPTURE 99 | if exist "%TargetDir%\%BackupName%.wim" set method=APPEND 100 | 101 | ::TODO:: Use DISM if OS is Windows 7 or newer and fall back to ImageX 102 | If Exist "%TargetDir%\imagex.exe" Set Tool="%TargetDir%\imagex.exe" 103 | If Exist "%~dp0imagex.exe" Set Tool="%~dp0imagex.exe" 104 | If Defined TOOL ( 105 | ::use a single WIM for all backups 106 | %Tool% /%method% /COMPRESS maximum %SourceDir% "%TargetDir%\%BackupName%.wim" "%BackupName% backup %YYYY%-%MM%-%DD%" "%BackupName% backup %YYYY%-%MM%-%DD% %HH%:%NN%" /CONFIG "%ExcFile%" 107 | ) else ( 108 | DISM.exe /%method%-Image /COMPRESS:max /CaptureDir:%SourceDir% /ImageFile:"%TargetDir%\%BackupName%.wim" /Name:"%BackupName%_%YYYY%-%MM%-%DD%" /Description:"%BackupName% backup %YYYY%-%MM%-%DD% %HH%:%NN%" /ConfigFile:"%ExcFile%" 109 | ) 110 | 111 | ::create 1 WIM per month 112 | ::if exist "%TargetDir%\%BackupName%-%yyyy%-%mm%.wim" set method=APPEND 113 | ::"%TargetDir%imagex.exe" /%method% %SourceDir% "%TargetDir%\%BackupName%-%yyyy%-%mm%.wim" "%BackupName% backup %YYYY%-%MM%-%DD%" "%BackupName% backup %YYYY%-%MM%-%DD% %HH%%:%MM%" /CONFIG %ExcFile% 114 | 115 | Call:MakeCopy %BackupName%*.wim 116 | goto:eof 117 | 118 | :MakeCopy 119 | ::copy to an alternate location 120 | if defined BackupDir ( 121 | if exist %BackupDir%\. ( 122 | echo copy to an alternate location 123 | start xcopy "%TargetDir%%1" "%BackupDir%" /C /V /Y /D 124 | ) 125 | ) 126 | goto:eof 127 | 128 | :EOF -------------------------------------------------------------------------------- /Backup and Compression/Backup-ToWIM.ini: -------------------------------------------------------------------------------- 1 | ;for WIMbackup, not specifically imaging 2 | [ExclusionList] 3 | ~*.* 4 | *.tmp 5 | *.lock 6 | thumbs.db 7 | winpepge.sys 8 | UserMan.ini 9 | LLU_Admin.Local.db 10 | LLU_Admin.Network.db 11 | thumbs.db 12 | pagefile.sys 13 | hiberfil.sys 14 | "\System Volume Information" 15 | $ntfs.log 16 | \bootmgr 17 | \InstalledRepository 18 | \LTIBootstrap.vbs 19 | \Build 20 | \Capture 21 | \inetpub\logs\*.* 22 | \Install 23 | \InstalledRepository 24 | \Installs 25 | \MININT 26 | \Packages 27 | \partitions.txt 28 | \RECYCLE.BIN 29 | \$RECYCLE.BIN 30 | \RECYCLER 31 | \Temp 32 | \VLpackages 33 | \Windows.old 34 | \Windows\Logs\*.* 35 | \Windows\CSC 36 | \Windows\Panther 37 | \Windows\SoftwareDistribution\Download\*.* 38 | \Windows\Temp\*.* 39 | \_SMSTaskSequence 40 | \idwlog 41 | \sources 42 | "\CrashPlan Inbound Backup\*.*" 43 | \ProgramData\CrashPlan\backupArchives\*.* 44 | \Users\Administrator\AppData\Local\GDIPFONTCACHEV1.DAT 45 | \Users\Administrator\AppData\Local\Temp\*.* 46 | "\Users\Administrator\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*" 47 | \Users\Owner\AppData\Local\Temp\*.* 48 | "\Users\Owner\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*" 49 | \Users\Administrator\Documents\*.* 50 | \Users\Administrator\Downloads\*.* 51 | 52 | [ExclusionList.disabled] 53 | \Users\Owner\Documents\*.* 54 | \Users\Owner\Downloads\*.* 55 | 56 | [CompressionExclusionList] 57 | *.mkv 58 | *.jpg 59 | *.mp4 60 | *.mp3 61 | *.zip 62 | *.cab 63 | *.7zip 64 | *.7z 65 | *.arj 66 | *.wim 67 | *.001 68 | *.rar 69 | \WINDOWS\inf\*.pnf -------------------------------------------------------------------------------- /Backup and Compression/gImagex.exe.stub: -------------------------------------------------------------------------------- 1 | Stub file to be replaced by the actual file -------------------------------------------------------------------------------- /Backup and Compression/imagex.exe.stub: -------------------------------------------------------------------------------- 1 | Stub file to be replaced by the actual file -------------------------------------------------------------------------------- /Backup and Compression/zPaq64.exe.stub: -------------------------------------------------------------------------------- 1 | Stub file to be replaced by the actual file from http://mattmahoney.net/dc/zpaq715.zip -------------------------------------------------------------------------------- /ConfigMgr/Connect-ConfigMgr.ps1: -------------------------------------------------------------------------------- 1 | Function Connect-ConfigMgr { 2 | #.Synopsis 3 | # Load Configuration Manager PowerShell Module 4 | #.Description 5 | # if SiteCode is not specified, detect it 6 | # if SiteServer is not specified, use the computer from PSDrive if it exists, otherwise use the current computer 7 | #.Link 8 | # http://blogs.technet.com/b/configmgrdogs/archive/2015/01/05/powershell-ise-add-on-to-connect-to-configmgr-connect-configmgr.aspx 9 | Param ( 10 | [Parameter(Mandatory=$false)][ValidateLength(3,3)][string]$SiteCode, 11 | [Parameter(Mandatory=$false)][ValidateLength(1,255)][string]$SiteServer 12 | ) 13 | If ($null -eq $Env:SMS_ADMIN_UI_PATH) { 14 | #import the module if it exists 15 | If ($null -eq (Get-Module ConfigurationManager)) { 16 | Write-Verbose 'Importing ConfigMgr PowerShell Module...' 17 | $TempVerbosePreference = $VerbosePreference 18 | $VerbosePreference = 'SilentlyContinue' 19 | try { 20 | ##Alternate method by https://kelleymd.wordpress.com/2015/03/26/powershell-module-reference-and-auto-load 21 | #R_e_q_u_i_r_e_s –Modules "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" 22 | #get-help Get-CMSite 23 | Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" 24 | } catch { 25 | Write-Error 'Failed Importing ConfigMgr PowerShell Module.' 26 | Throw $_ 27 | } 28 | $VerbosePreference = $TempVerbosePreference 29 | Remove-Variable TempVerbosePreference 30 | } else { 31 | Write-Verbose "The ConfigMgr PowerShell Module is already loaded." 32 | } 33 | # If SiteCode was not specified detect it 34 | If ([string]::IsNullOrEmpty($SiteCode)) { 35 | try { 36 | $SiteCode = (Get-PSDrive -PSProvider CMSite -ErrorAction Stop).Name 37 | } catch { 38 | Throw $_ 39 | } 40 | } 41 | # Connect to the site's drive if it is not already present 42 | if ($null -eq (Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue)) { 43 | Write-Verbose -Message "Creating ConfigMgr Site Drive $($SiteCode):\ on server $SiteServer" 44 | # If SiteCode was not specified use the current computer 45 | If ([string]::IsNullOrEmpty($SiteServer)) { 46 | $SiteServer = $env:ComputerName 47 | } 48 | try { 49 | New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $SiteServer -Scope Global #-Persist 50 | } catch { 51 | Throw $_ 52 | } 53 | } 54 | #change location to the ConfigMgr Site 55 | try { 56 | Push-Location "$($SiteCode):\" 57 | Pop-Location 58 | } catch { 59 | Write-Error "Error connecting to the ConfigMgr site" 60 | Throw $_ 61 | } 62 | } else { 63 | Throw "The ConfigMgr PowerShell Module does not exist! Install the ConfigMgr Admin Console first." 64 | } 65 | }; Set-Alias -Name 'Connect-CMSite' -Value 'Connect-ConfigMgr' -Description 'Load the ConfigMgr PowerShell Module and connect to a ConfigMgr site' -------------------------------------------------------------------------------- /ConfigMgr/Document/Get-MCMActiveDeployments.sql: -------------------------------------------------------------------------------- 1 | --Deployments for Packages which have not expired 2 | select A.OfferName [Advertisement], P.Manufacturer, P.Name, P.Version, A.PkgProgram, P.LastRefresh [Package Updated in SCCM] 3 | , A.PresentTime 4 | , Case 5 | When A.ExpirationTime = A.PresentTime Then '12/31/2199' 6 | Else A.ExpirationTime 7 | End as [ExpirationTime] 8 | from vAdvertisement AS A 9 | inner join vPackage AS P on A.PkgID = P.PkgID 10 | where (A.ExpirationTime > GetDate() OR A.PresentTime = A.ExpirationTime) 11 | order by P.Manufacturer, P.Name, P.Version --A.ExpirationTime 12 | 13 | --Packages with Deployments which have not expired 14 | select DISTINCT P.Manufacturer, P.Name, P.Version--, A.PkgProgram 15 | , P.LastRefresh [Package Updated in SCCM] 16 | from vAdvertisement AS A 17 | inner join vPackage AS P on A.PkgID = P.PkgID 18 | where (A.ExpirationTime > GetDate() OR A.PresentTime = A.ExpirationTime) 19 | order by P.Manufacturer, P.Name, P.Version --A.ExpirationTime -------------------------------------------------------------------------------- /ConfigMgr/Document/Get-MCMAdminConsoleUsers.ps1: -------------------------------------------------------------------------------- 1 | #region ####### ConfigMgr Administrative users #####################################################################> 2 | $SiteCode = 'LAB' 3 | $SiteServer = 'CMPrimary.contoso.com' 4 | $ExportFile = 'C:\Data\Get-MECMAdminConsoleUsers.csv' 5 | Push-Location -Path "$SiteCode`:" 6 | $CMAdminUsers = Get-CMAdministrativeUser | Select-Object LogonName, IsGroup 7 | Pop-Location 8 | $CMAdminUserList = @() 9 | ForEach ($CMAdminUser in $CMAdminUsers) { 10 | Write-Output $CMAdminUser.LogonName 11 | If ($CMAdminUser.IsGroup -eq $true) { 12 | $CMAdminUserIDs = (Get-WmiObject -ComputerName $SiteServer -Namespace "root\SMS\site_$($SiteCode)" -Query "Select UniqueUserName from SMS_R_User where UserGroupName like `"$($CMAdminUser.LogonName.replace('\','\\'))`"").UniqueUserName 13 | } Else { 14 | $CMAdminUserIDs = (Get-WmiObject -ComputerName $SiteServer -Namespace "root\SMS\site_$($SiteCode)" -Query "Select * from SMS_R_User where UniqueUserName = `"$($CMAdminUser.LogonName.replace('\','\\'))`"").UniqueUserName 15 | } 16 | ForEach ($CMAdminUserID in $CMAdminUserIDs) { 17 | $CMAdminUserList += @(Get-WmiObject -ComputerName $SiteServer -Namespace "root\SMS\site_$($SiteCode)" -Query "Select * from SMS_R_User where UniqueUserName = `"$($CMAdminUserID.replace('\','\\'))`"" | Select-Object @{N = 'Group'; E = { $CMAdminUser.LogonName } }, UniqueUserName, ResourceID, ResourceType, UserName, Name, displayname, WindowsNTDomain, distinguishedName, FullDomainName, FullUserName, UserPrincipalName, mail, mobile, telephoneNumber, UserGroupName) 18 | } 19 | } 20 | $CMAdminUserList | Select-Object Group, UniqueUserName, ResourceID, ResourceType, UserName, Name, displayname, WindowsNTDomain, distinguishedName, FullDomainName, FullUserName, UserPrincipalName, mail, mobile, telephoneNumber | Export-Csv -Path "filesystem::$($ExportFile)" -NoTypeInformation 21 | Write-Output "Exported $($CMAdminUserList.Count) users to $ExportFile" 22 | #endregion ####### ConfigMgr Administrative users #####################################################################> 23 | -------------------------------------------------------------------------------- /ConfigMgr/Document/Get-MCMInfo.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | set myCompany=Contoso 4 | set myDomain=contoso.com 5 | set myForest=contoso.com 6 | set myDCserver=DC1 7 | set myCMServer=CM1 8 | set mySQLServer=SQL1 9 | set myUserName=ConfigMgr Admin 10 | set mySaveDir=%UserProfile%\Documents\ConfigMgr Documentation 11 | 12 | If /I [%1]==[/?] goto:Help 13 | If /I [%1]==[-?] goto:Help 14 | If /I [%1]==[/h] goto:Help 15 | If /I [%1]==[-h] goto:Help 16 | If /I [%1]==[/help] goto:Help 17 | If /I [%1]==[-help] goto:Help 18 | goto:Begin 19 | :Help 20 | echo =============================================================================== 21 | echo .Synopsis 22 | echo Document a Microsoft System Center Configuration Manager environment using 23 | echo scripts. 24 | echo .Description 25 | echo Scripted Documentation 26 | echo .Functionality 27 | echo Execute scripts to produce .XML, .HTML and .DOCX reports 28 | echo .Parameters 29 | echo [/h] [/help] display this help information 30 | echo .Notes 31 | echo === References and Sources === 32 | echo DocumentCM12R2v2.ps1 version 1.00 updated 2015/04/06 by David O'Brien, Carl Webster, Michael B. Smith, Iain Brighton, Jeff Wouters, Barry Schiffer 33 | echo CM12sydi-143.vbs version 1.43 updated 2013/12/24 by Garth Jones at http://www.enhansoft.com/downloads/vbs/CM12Sydi-143.zip 34 | echo sydi-server.vbs version 2.4 updated 2014/10/26 by http://sydiproject.com 35 | echo sydi-sql.vbs version 0.8 updated 2005/04/05 by http://sydiproject.com 36 | echo ADDS_Inventory_v1_1.ps1 version 1.11 updated 2015/07/08 by http://www.CarlWebster.com 37 | echo === Change Log History === 38 | echo 2015/09/23 by Chad.Simmons@CatapultSystems.com - Created 39 | echo ================================================================================ 40 | goto:eof 41 | 42 | :Begin 43 | SET SourceDir=%~dp0 44 | SET SourceDir=%SourceDir:~,-1% 45 | 46 | If NOT Defined mySaveDir set mySaveDir=%SourceDir%\ConfigMgr Documentation 47 | If NOT EXIST "%mySaveDir%" MkDir "%mySaveDir%" 48 | 49 | :Get_ADInventory 50 | pushd "%SourceDir%\ADDS" 51 | PowerShell -ExecutionPolicy Bypass -File .\ADDS_Inventory_V1_1.ps1 -AddDateTime -MSWord -CompanyName "%myCompany%" -UserName "%myUserName%" -Hardware -ADForest %myForest% -ComputerName %myDCserver% 52 | popd 53 | 54 | :Get_SQLInventory 55 | pushd "%SourceDir%\SYDI" 56 | set myServer=%mySQLServer% 57 | set myServerFQDN=%myServer%.%myDomain% 58 | cscript.exe sydi-server.vbs -wafgsu -rc -f11 -ex -d -t%myServerFQDN% -o"%mySaveDir%\%myServer%.xml" 59 | cscript.exe sydi-server.vbs -wafgsu -rc -f11 -ex -sh -d -t%myServerFQDN% -o"%mySaveDir%\%myServer%.html" 60 | cscript.exe sydi-server.vbs -wafgsu -rc -f11 -ew -d -t%myServerFQDN% -o"%mySaveDir%\%myServer%.docx" 61 | cscript.exe sydi-sql.vbs -S -l1 -ex -s -t%myServerFQDN% -o"%mySaveDir%\%myServer%_SQL.xml" 62 | cscript.exe sydi-sql.vbs -S -l1 -ex -sh -t%myServerFQDN% -o"%mySaveDir%\%myServer%_SQL.html" 63 | cscript.exe sydi-sql.vbs -S -l1 -ew -sh -d -t%myServerFQDN% -o"%mySaveDir%\%myServer%_SQL.docx" 64 | popd 65 | 66 | :Get_ConfigMgrInventory 67 | set myServer=%myCMServer% 68 | set myServerFQDN=%myServer%.%myDomain% 69 | pushd "%SourceDir%\SYDI" 70 | cscript.exe sydi-server.vbs -wafgsu -rc -f11 -ex -s -t%myServerFQDN% -o"%mySaveDir%\%myServer%.xml" 71 | cscript.exe sydi-server.vbs -wafgsu -rc -f11 -ex -sh -t%myServerFQDN% -o"%mySaveDir%\%myServer%.html" 72 | cscript.exe sydi-server.vbs -wafgsu -rc -f11 -ew -d -t%myServerFQDN% -o"%mySaveDir%\%myServer%.docx" 73 | cscript.exe CM12Sydi-143.vbs -wacmpqs -f11 -ew -t%myServerFQDN% -o"%mySaveDir%\%myServer%_ConfigMgr.docx" 74 | popd 75 | PowerShell -ExecutionPolicy Bypass -File .\DocumentCM12R2v2.ps1 -AddDateTime -MSWord -CompanyName "%myCompany%" -UserName "%myUserName%" -Software -ListAllInformation -SMSProvider %myServerFQDN% 76 | 77 | :eof 78 | -------------------------------------------------------------------------------- /ConfigMgr/Document/Get-MCMPackageSize.ps1: -------------------------------------------------------------------------------- 1 | $PackageIDsFile = "$env:UserProfile\Documents\PackageIDs.txt" 2 | $PackageIDs = Import-CSV -Path $PackageIDsFile -Header 'PackageID' 3 | $PackageIDs | Add-Member -MemberType NoteProperty -Name PackageSize -Value $null 4 | $PackageIDs | Add-Member -MemberType NoteProperty -Name PackageFullName -Value $null 5 | $PackageIDs | Add-Member -MemberType NoteProperty -Name LastUpdated -Value $null 6 | $PackageIDs | Get-Member 7 | #$PackageIDs = $PackageIDs | Select -First 5 8 | #$PackageIDs | Select -First 2 | Format-Table -AutoSize 9 | 10 | If ($PackageIDs.count -gt 50 -and $AllPackages.count -eq 0) { $AllPackages = Get-CMPackage } 11 | 12 | ForEach ($Package in $PackageIDs) { 13 | If ($AllPackages.count -le 1) { 14 | $AllPackages = Get-CMPackage -ID $Package.PackageID 15 | } 16 | $CurrentPackage = ($AllPackages | Where-Object { $_.PackageID -eq $Package.PackageID }) 17 | $Package.PackageSize = ($CurrentPackage).PackageSize 18 | $Package.PackageFullName = ($CurrentPackage).Manufacturer 19 | $Package.PackageFullName = $Package.PackageFullName+" "+($CurrentPackage).Name 20 | $Package.PackageFullName = $Package.PackageFullName+" "+($CurrentPackage).Version 21 | $Package.PackageFullName = $Package.PackageFullName.Trim() 22 | $Package.LastUpdated = ($CurrentPackage).LastRefreshTime 23 | } 24 | 25 | $PackageIDs | Export-CSV -Path "$PackageIDsFile.csv" -NoTypeInformation 26 | $PackageIDs | Sort-Object PackageSize | Format-Table -AutoSize 27 | -------------------------------------------------------------------------------- /ConfigMgr/Document/Get-MCMPackagesConfiguredForPackageShares.ps1: -------------------------------------------------------------------------------- 1 | #.Synopsis 2 | # Get all ConfigMgr Packages which are Share enabled 3 | #.Description 4 | # These packages have the setting "Copy the content in this package to a package share on distribution points" enabled 5 | #.Link 6 | # How To: List Packages that are Configured to use a Package Share in ConfigMgr 2012 7 | # https://gregramsey.net/2013/02/14/how-to-list-packages-that-are-configured-to-use-a-package-share-in-configmgr-2012/ 8 | #.Notes 9 | # http://myitforum.com/myitforumwp/2011/10/21/sccm-flags-updated-advertflags-boundaryflags-deviceflags-imageflags-offerflags-pkgflags-programflags-referenceimageflags-remoteclientflags-timeflags-ts_flags/ 10 | # PkgFlags on MSDN https://msdn.microsoft.com/en-us/library/hh948196.aspx 11 | # https://msdn.microsoft.com/en-us/library/cc146062.aspx 12 | 13 | 14 | #Load Configuration Manager PowerShell Module 15 | #.Link http://blogs.technet.com/b/configmgrdogs/archive/2015/01/05/powershell-ise-add-on-to-connect-to-configmgr-connect-configmgr.aspx 16 | If ($null -ne $Env:SMS_ADMIN_UI_PATH) { 17 | Try { 18 | Write-Host "Importing ConfigMgr PowerShell Module..." 19 | Import-Module ((Split-Path $env:SMS_ADMIN_UI_PATH)+"\ConfigurationManager.psd1") 20 | ## Another method ## Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1") 21 | ## Another method ## Import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1') 22 | Write-Host "Executed `"Import-module `'((Split-Path $env:SMS_ADMIN_UI_PATH)+"\ConfigurationManager.psd1")`'`"" 23 | $SiteCode = (Get-PSDrive -PSProvider CMSITE).Name 24 | Push-Location "$($SiteCode):\" 25 | #Dir 26 | Pop-Location 27 | Write-Host "Detected ConfigMgr Site of $SiteCode. Execute the command 'CD $($SiteCode):\' before running any ConfigMgr cmdlet" -ForegroundColor Green 28 | } Catch { 29 | Write-Error "Executing `"Import-module `'((Split-Path $env:SMS_ADMIN_UI_PATH)+"\ConfigurationManager.psd1")`'`"" 30 | } 31 | } 32 | 33 | 34 | $Packages = Get-CMPackage | Where-Object { $_.pkgflags -eq ($_.pkgflags -bor 0x80) } #80 hex is 128 decimal 35 | $Packages | Select-Object PackageID, Manufacturer, Name, Version, LastRefreshTime, PackageSize, PkgFlags, ShareName 36 | 37 | -------------------------------------------------------------------------------- /ConfigMgr/Document/Get-MCMSoftwareUpdatePackageSize.ps1: -------------------------------------------------------------------------------- 1 | $AllPackages = Get-CMSoftwareUpdateDeploymentPackage 2 | $MyPackages = $AllPackages | Select-Object PackageID, Name, PackageSize, LastRefreshTime, PkgSourcePath 3 | $MyPackages | Add-Member -MemberType NoteProperty -Name MBTotal -Value $null 4 | #$MyPackages | Add-Member -MemberType NoteProperty -Name UpdatesTotal -Value $null 5 | #$MyPackages | Add-Member -MemberType NoteProperty -Name UpdatesSuperseded -Value $null 6 | #$MyPackages | Add-Member -MemberType NoteProperty -Name UpdatesExpired -Value $null 7 | $MyPackages | ForEach-Object { $_.MBTotal = [math]::Round($_.PackageSize/2014,1) } 8 | $MyPackages | Export-CSV -Path "ConfigMgr Software Update Deployment Packages.csv" -NoTypeInformation 9 | $MyPackages | Sort-Object PackageSize | Select-Object PackageID, MBTotal, Name, LastRefreshTime | Format-Table -AutoSize 10 | -------------------------------------------------------------------------------- /ConfigMgr/Document/get-MCMDPRateLimits.ps1: -------------------------------------------------------------------------------- 1 | function Get-DPRateLimits 2 | { 3 | <# 4 | .SYNOPSIS 5 | Query for Distribution Points that have RateLimits set or not. 6 | .DESCRIPTION 7 | Query for Distribution Points that have RateLimits set or not. This is set on the Rate Limits Tab of the Distribution point Properties 8 | in the Console. The equivalent action in the gui to that if the "Unlimited when sending to this destination" radio button is NOT set, then the Rate limits are enabled. If it is set then Rate Limits are not enabled. 9 | .PARAMETER -SiteServer 10 | Server name of the Primary Site. Required 11 | .PARAMETER -SiteCode 12 | Site Code of the Primary Site used in the -SiteServer parameter. Required 13 | .PARAMETER -Enable 14 | Used to specify to query for systems with Rate limits enabled or disabled. Only accepts $true or $false 15 | This is an optional parameter. By default it will be $true. 16 | .EXAMPLE 17 | Get-DPRateLimits -SiteServer CMPrimary -SiteCode LAB -Enable $true 18 | Query for Distribution Points with Rate Limits enabled 19 | .EXAMPLE 20 | Get-DPRateLimits -SiteServer CMPrimary -SiteCode LAB -Enable $false 21 | Query for Distribution Points without Rate Limits enabled 22 | .Notes 23 | Author: Jon Warnken jon.warnken@gmail.com 24 | Revisions: 25 | 1.0 06/23/2014 - Original creation. 26 | 27 | #> 28 | [CmdletBinding()] 29 | 30 | param ( 31 | [Parameter(Mandatory=$true,Position=1)] 32 | [string]$SiteServer, 33 | [Parameter(Mandatory=$true,Position=2)] 34 | [string]$SiteCode, 35 | [Parameter(Mandatory=$false,Position=3)] 36 | [Boolean]$Enable=$True 37 | ) 38 | 39 | if($Enable){ 40 | $dp = Get-WmiObject -ComputerName $SiteServer -namespace "root\sms\site_$SiteCode" -query "select * from SMS_SCI_address where UnlimitedRateForAll = 'False'" 41 | }else{ 42 | $dp = Get-WmiObject -ComputerName $SiteServer -namespace "root\sms\site_$SiteCode" -query "select * from SMS_SCI_address where UnlimitedRateForAll = 'True'" 43 | } 44 | return $dp 45 | } -------------------------------------------------------------------------------- /ConfigMgr/Install and Configure/Set-DataDeduplication.ps1: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | #.SYNOPSIS 3 | # Set-DataDeduplication.ps1 4 | # Enable Windows Server Data Deduplication excluding ConfigMgr/SCCM Content Source Folders, the ConfigMgr install folder, and SQL Server install, data, and log folders 5 | #.PARAMETER Drive 6 | # Specifies the drive to dedupe. 7 | #.EXAMPLE 8 | # Set-DataDeduplication.ps1 -Drive 'E' 9 | #.LINK 10 | # https://cloudblogs.microsoft.com/enterprisemobility/2014/02/18/configuration-manager-distribution-points-and-windows-server-2012-data-deduplication 11 | # https://deploymentresearch.com/Research/Post/409/Using-Data-DeDuplication-with-ConfigMgr-2012-R2 12 | # http://wmug.co.uk/wmug/b/r0b/archive/2014/02/21/windows-2012-server-deduplication-and-configmgr-2012 13 | # https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/hh831434(v=ws.11) 14 | # https://docs.microsoft.com/en-us/windows-server/storage/data-deduplication/install-enable 15 | #.NOTES 16 | # This script is maintained at https: //github.com/ChadSimmons/Scripts 17 | # Additional information about the function or script. 18 | # ========== Change Log History ========== 19 | # - 2018/09/25 by Chad.Simmons@CatapultSystems.com - updated ValidatePattern and IncludeFolders 20 | # - 2016/12/21 by Chad.Simmons@CatapultSystems.com - Created 21 | # - 2016/12/21 by Chad@ChadsTech.net - Created 22 | ################################################################################ 23 | #region ######################### Parameters and variable initialization #### 24 | [CmdletBinding()] #(SupportsShouldProcess=$false, ConfirmImpact="Low") 25 | Param ( 26 | [Parameter(Mandatory=$true)][ValidateLength(1,1)][ValidatePattern('[d-zD-Z]')][ValidateScript({Test-Path "$_\" -PathType 'Container'})] 27 | [string]$Drive = 'E' 28 | ) 29 | #region ######################### Debug code 30 | <# 31 | $Drive = 'D' 32 | #> 33 | #endregion ######################### Debug code 34 | 35 | If ($Drive -notlike '*:') { $Drive = $Drive + ':'} 36 | 37 | $CustomNoCompressionFileTypes = @('7z','mp3','mp4','mkv','jpg','png','zpaq','bak','wim') 38 | $IncludeFolders = @('SCCMContentLib','SMS_DP$',"SMSPKG$($Drive)$",'SMSPKGSIG','SMSSIG$','Backup','Install','Installs') 39 | $ExcludeFolders = (Get-ChildItem -Path "$Drive\" -Directory | Where-Object { $_.Name -notin $IncludeFolders }).Name #All non-included root folders 40 | #endregion ##################################################################### 41 | 42 | try { 43 | Write-Output 'Install the Windows feature' 44 | Import-Module ServerManager 45 | $Result = Add-WindowsFeature -Name FS-Data-Deduplication 46 | If ($Result.RestartNeeded -eq 'Yes') { 47 | Write-Warning 'Restart Required' 48 | break 49 | } 50 | Write-Output 'Import PowerShell Module' 51 | Import-Module Deduplication 52 | Write-Output 'Enable on volume' 53 | Enable-DedupVolume $Drive 54 | 55 | try { 56 | Write-Output 'Set exclusions' 57 | Set-DedupVolume –Volume $Drive -ExcludeFolder @((Get-DedupVolume -Volume $Drive | Select-Object -ExpandProperty ExcludeFolder) + @($ExcludeFolders | ForEach-Object { "`\$_" })) 58 | Set-DedupVolume –Volume $Drive -NoCompressionFileType @(@(Get-DedupVolume -Volume $Drive | Select-Object -ExpandProperty NoCompressionFileType) + $CustomNoCompressionFileTypes) 59 | Write-Output 'Start deduplication and monitor progress' 60 | Start-DedupJob –Volume $Drive -Type Optimization -Preempt 61 | Get-DedupJob -Volume $Drive 62 | Get-DedupStatus -Volume $Drive 63 | } catch { 64 | Write-Error $_ 65 | } 66 | } catch { 67 | Write-Error $_ 68 | } 69 | Write-Output 'Show the existing / built-in schedules' 70 | Get-DedupSchedule 71 | Get-DedupVolume -Volume $Drive | Select-Object -ExpandProperty NoCompressionFileType 72 | Get-DedupVolume -Volume $Drive | Select-Object -ExpandProperty ExcludeFolder 73 | Get-DedupVolume -Volume $Drive | Select-Object Volume, Enabled, MinimumFileAgeDays, MinimumFileSize, NoCompress, OptimizeInUseFiles, SavedSpace, SavingsRate, UnoptimizedSize, UsedSpace 74 | Write-Output "=== OPTIONAL ===`nSet-DedupSchedule -Name Daily -Cores 1 -Days @('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday') -DurationHours 4 -Enabled -Memory 50 -Priority Low -StopWhenSystemBusy $true -Type Optimization -Start 01:45" 75 | -------------------------------------------------------------------------------- /ConfigMgr/Install and Configure/Start-DataDeduplication.ps1: -------------------------------------------------------------------------------- 1 | #Force Data Deduplication job to run now 2 | Import-Module deduplication 3 | $Drive = 'I:' 4 | Get-DedupStatus -Volume $Drive | Format-List 5 | Start-DedupJob -Volume $Drive -Type Optimization -Preempt -Wait 6 | Get-DedupStatus -Volume $Drive | Format-List -------------------------------------------------------------------------------- /ConfigMgr/Migrate, Export and Import/Export-MCMApplications.ps1: -------------------------------------------------------------------------------- 1 | $ExportPath = '\\Lab-CM1\Source\Export' 2 | $SiteCode = 'LAB' 3 | 4 | $MyLocation = Get-Location 5 | 6 | Set-Location "$env:UserProfile" 7 | If (-not(Test-Path -Path "$ExportPath\Apps")) { New-Item -Path "$ExportPath" -Name 'Apps' -ItemType Directory -ErrorAction SilentlyContinue } 8 | Set-Location "$SiteCode`:\" 9 | $Apps = Get-CMApplication 10 | $i = 0 11 | ForEach ($App in $Apps) { 12 | $i++ 13 | Write-Progress -Activity "Exporting ConfigMgr Applications" -Status "[$i of $($Apps.Count)] $($App.Manufacturer) $($App.LocalizedDisplayName) $($App.SoftwareVersion)" -PercentComplete $($($i / $($Apps.Count)) * 100) 14 | Write-Output "Exporting ConfigMgr Application $i of $($Apps.Count) : $($App.Manufacturer) $($App.LocalizedDisplayName) $($App.SoftwareVersion)".Trim() 15 | $ExportFile = "$ExportPath\Apps\App.$($App.Manufacturer)_$($App.LocalizedDisplayName)_$($App.SoftwareVersion).zip" 16 | Set-Location "$env:UserProfile" 17 | If (Test-Path -Path $ExportFile) { 18 | Remove-Item -Path "$ExportFile" -Force 19 | } 20 | Set-Location "$SiteCode`:\" 21 | Export-CMApplication -InputObject $App -Path "$ExportFile" -Comment $("$($App.Manufacturer) $($App.LocalizedDisplayName) $($App.SoftwareVersion)".Trim()) -OmitContent #-IgnoreRelated 22 | } 23 | 24 | Set-Location "$env:UserProfile" 25 | #region Create Zip archive file 26 | Add-Type -Assembly System.IO.Compression.FileSystem 27 | $archiveFile = "$ExportPath\Apps.$(Get-Date -format 'yyyyMMdd_HHmm').zip" 28 | [System.IO.Compression.ZipFile]::CreateFromDirectory("$ExportPath\Apps", $archiveFile, $([System.IO.Compression.CompressionLevel]::Optimal), $false) 29 | #endregion 30 | 31 | Set-Location $MyLocation 32 | -------------------------------------------------------------------------------- /ConfigMgr/Migrate, Export and Import/See new repo just for this!.txt: -------------------------------------------------------------------------------- 1 | https://github.com/ChadSimmons/ExportMicrosoftEndpointManager 2 | -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/7-Zip/7-zip File Manager and Extra files.stub: -------------------------------------------------------------------------------- 1 | stub file to be replaced with real file -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/AddMeToCollection.vbs: -------------------------------------------------------------------------------- 1 | '========================================================================== 2 | ' 3 | ' NAME: AddMeToCollection.vbs 4 | ' 5 | ' AUTHOR: Vinay, Microsoft 6 | ' DATE : 8/7/2010 7 | ' 8 | ' Updated 2014/11/06 by Chad.Simmons@CatapultSystems.com 9 | ' - corrected syntax error in last line 10 | ' - added exit/return codes to wscript.quit calls 11 | ' 12 | ' COMMENT: Script to add Unknown Computer to a specified collection during OSD 13 | ' USAGE: cscript AddMeToCollection.vbs %_SMSTSClientIdentity% 14 | '========================================================================== 15 | On Error Resume Next 16 | Dim arrArguments 17 | Set arrArguments = WScript.Arguments 18 | If arrArguments.Count <> 3 Then 19 | WScript.Echo "Usage: cscript AddMeToCollection.vbs %_SMSTSClientIdentity%" 20 | WScript.Echo " and needs to be specified, but last parameter needs to be used as is." 21 | WScript.Echo "Note: %_SMSTSClientIdentity% is the 41 character ConfigMgr Unique ID in the format 'GUID:xxxxxxx'" 22 | WScript.Echo "see http://blogs.msdn.com/b/vinpa/archive/2010/09/01/how-to-add-a-known-unknown-computer-to-a-specified-collection-during-os-deployment.aspx" 23 | WScript.Quit 87 'ERROR_INVALID_PARAMETER 24 | End If 25 | 26 | Dim strServer, strCollID, strProvNamespace 27 | Dim strComputerName, strGUID, strResourceID 28 | Dim strUser, strPassword 29 | strResourceID = 0 30 | 31 | strServer = arrArguments(0) 32 | strCollID = arrArguments(1) 33 | strGUID = arrArguments(2) 34 | 35 | WScript.Echo "" 36 | WScript.Echo "===================================" 37 | WScript.Echo " ADDING COMPUTER TO COLLECTION" 38 | WScript.Echo "===================================" 39 | WScript.Echo "Site Server specified: " & strServer 40 | WScript.Echo "Collection ID specified: " & strCollID 41 | WScript.Echo "SMS Client " & strGUID 42 | 43 | 'Get the computer name 44 | Set oNet = CreateObject("WScript.Network") 45 | strComputerName = oNet.ComputerName 46 | WScript.Echo "Computer Name: " & strComputerName 47 | Set oNet = Nothing 48 | 49 | 'Connect to root/sms namespace on SMS Site Server to find the Provider Namespace 50 | Set objLocator = CreateObject("WbemScripting.SWbemLocator") 51 | Set oWbem = objLocator.ConnectServer(strServer, "root/sms") 52 | If Err.number <> 0 Then 53 | WScript.Echo "Error connecting to root\sms namespace to find Provider Location. Exiting!" 54 | WScript.Echo "Error = " & Err.number & " - " & Err.Description 55 | WScript.Quit Err.number 56 | End If 57 | Set colNameSpace = oWbem.ExecQuery("SELECT * FROM SMS_ProviderLocation") 58 | For Each item in colNameSpace 59 | WScript.Echo "SMS Provider Namespace = " & item.NamespacePath 60 | strProvNamespace = item.NamespacePath 61 | Next 62 | 63 | 'Connect to the Provider Namespace 64 | Set oWbem = objLocator.ConnectServer(strServer, strProvNamespace) 65 | If Err.number <> 0 Then 66 | WScript.Echo "Error connecting to SMS Provider namespace. Exiting!" 67 | WScript.Echo "Error = " & Err.number & " - " & Err.Description 68 | WScript.Quit Err.number 69 | Else 70 | WScript.Echo "Successfully Connected to the SMS Provider Namespace" 71 | End If 72 | 73 | 'Find out the Resource ID of the computer by querying SMS_R_System Class against the SMS GUID 74 | Set colResources = oWbem.ExecQuery("SELECT ResourceID FROM SMS_R_System WHERE SMSUniqueIdentifier = '" & strGUID & "'") 75 | For Each oResource In colResources 76 | strResourceID = oResource.ResourceID 77 | WScript.Echo "Resource ID = " & strResourceID 78 | Next 79 | 80 | 'If Resource ID was not found, exit gracefully 81 | If strResourceID = 0 Then 82 | WScript.Echo "Could not find the Resource ID for the computer. Exiting!" 83 | WScript.Quit 1169 'ERROR_NO_MATCH 84 | End If 85 | 86 | 'Verify if the specified collection exists 87 | Set oCollection = oWbem.Get("SMS_Collection.CollectionID=" & """" & strCollID & """") 88 | If oCollection.Name = "" Then 89 | WScript.Echo "Specified Collection (" & strCollID & ") was Not Found. Exiting!" 90 | WScript.Quit 1168 'ERROR_NOT_FOUND 91 | End If 92 | 93 | 'Create a Direct Membership rule 94 | Set oDirectRule = oWbem.Get("SMS_CollectionRuleDirect").SpawnInstance_ () 95 | oDirectRule.ResourceClassName = "SMS_R_System" 96 | oDirectRule.ResourceID = strResourceID 97 | oDirectRule.RuleName = strComputerName & " - SMSTS" 98 | 99 | 'Add the Direct Membership Rule to the specified collection 100 | oCollection.AddMembershipRule oDirectRule 101 | If Err.Number <> 0 Then 102 | WScript.Echo "Could not add the computer to the specified collection. Exiting!" 103 | WScript.Echo "Error = " & Err.number & " - " & Err.Description 104 | WScript.Quit Err.number 105 | Else 106 | WScript.Echo strComputerName & " successfully added To " & strCollID 107 | End If 108 | 109 | WScript.Echo "===================================" 110 | WScript.Echo "" 111 | 112 | Set objLocator = Nothing 113 | Set oWbem = Nothing 114 | Set oCollection = Nothing 115 | Set oDirectRule = Nothing -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/ServiceUI.exe.stub: -------------------------------------------------------------------------------- 1 | stub file to be replaced with real file -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/Set-ImageInfo-Deploy.vbs: -------------------------------------------------------------------------------- 1 | '****************************************************************************** 2 | ' Name: Set-ImageInfo-Deploy.vbs 3 | ' Description: Sets System Image Information during a Deploy event 4 | ' Author: Chad.Simmons@CatapultSystems.com 5 | ' Date: 20140612 6 | '****************************************************************************** 7 | Option Explicit 8 | On Error Resume Next 9 | 10 | '************************* DO NOT MODIFY BELOW THIS LINE ************************* 11 | Dim objShell : Set objShell = CreateObject("WScript.Shell") 12 | Const RegPath="HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Image Information\" 13 | 14 | ' Set Image Information 15 | objShell.RegWrite RegPath & "InstallDate", YYYYMMDD(Now()), "REG_SZ" 16 | 17 | Function YYYYMMDD(dDate) 18 | On Error Resume NEXT 19 | If Not IsDate(dDate) Then dDate = Now() 'Set dDate to NOW() if it is not a date 20 | 'Parse out each component from the full date time stamp 21 | Dim strYear : strYear = Year(dDate) 22 | IF strYear < 80 Then strYear = "20" & strYear 'The year < 80 then assume 2000's 23 | IF Len(strYear) < 3 Then strYear = "19" & strYear 'The year is still 2 digits so assume 1900's 24 | YYYYMMDD = strYear & Right("0" & Month(dDate),2) & Right("0" & Day(dDate),2) 25 | On Error Goto 0 26 | End Function -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/Set-OEMInfo.vbs: -------------------------------------------------------------------------------- 1 | '****************************************************************************** 2 | ' Name: Set-OEMInfo.vbs 3 | ' Description: Sets OEM Info (Manufacturer, Model, etc.) 4 | ' Author: Chad.Simmons@CatapultSystems.com 5 | ' Date: 20140612 6 | '****************************************************************************** 7 | Option Explicit 8 | On Error Resume Next 9 | 10 | Const MFGCustomText = " (provisioned by Catapult Systems)" 11 | Const strRegPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation\" 12 | Dim objWMIService, colWMI, objWMI, Manufacturer, Model, objShell, colCSP 13 | 14 | Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2") 15 | Set objShell = wscript.CreateObject("wscript.shell") 16 | 17 | Set colWMI = objWMIService.ExecQuery("Select Manufacturer,Model from Win32_ComputerSystem") 18 | For Each objWMI In colWMI 19 | Model = objWMI.Model 20 | Manufacturer = objWMI.Manufacturer 21 | Next 22 | 23 | 'sanatize the manufacturer 24 | If Left(UCase(Manufacturer), 3) = "IBM" Or Left(UCase(Manufacturer), 6) = "LENOVO" Then 25 | Manufacturer = "Lenovo" 26 | Set colCSP = objWMIService.ExecQuery("Select Version from Win32_ComputerSystemProduct") 27 | For Each objWMI In colCSP 28 | Model = objWMI.Version 29 | Next 30 | ElseIf Left(UCase(Manufacturer), 4) = "DELL" Then 31 | Manufacturer = "Dell" 32 | End If 33 | 34 | 'reg write MFG,Model 35 | objShell.RegWrite strRegPath & "Manufacturer", Manufacturer & MFGCustomText, "REG_SZ" 36 | objShell.RegWrite strRegPath & "Model", Model, "REG_SZ" -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/Set-OSDComputerNamePrompt.ps1: -------------------------------------------------------------------------------- 1 | #.SYNOPSIS 2 | # Set-OSDComputerNamePrompt.ps1 3 | # Prompt and set the ConfigMgr (SCCM) Operating System Deployment (OSD) Task Sequence variable OSDComputerName 4 | #.EXAMPLE 5 | # ServiceUI.exe -process:TSProgressUI.exe %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File Set-OSDComputerNamePrompt.ps1 6 | #.LINK https://gist.github.com/davegreen/453cee5ef2db1063a007 7 | #.LINK https://msendpointmgr.com/2013/10/02/prompt-for-computer-name-during-osd-with-powershell/ 8 | 9 | Function Load-Form { 10 | $Form.Controls.Add($TBComputerName) 11 | $Form.Controls.Add($GBComputerName) 12 | $Form.Controls.Add($ButtonOK) 13 | $Form.Add_Shown({$Form.Activate()}) 14 | [void] $Form.ShowDialog() 15 | } 16 | 17 | Function Set-OSDComputerName { 18 | $ErrorProvider.Clear() 19 | if ($TBComputerName.Text.Length -eq 0) { 20 | $ErrorProvider.SetError($GBComputerName, "Please enter a computer name.") 21 | } elseif ($TBComputerName.Text.Length -gt 15) { 22 | $ErrorProvider.SetError($GBComputerName, "Computer name cannot be more than 15 characters.") 23 | } elseif ($TBComputerName.Text -match "^[-_]|[^a-zA-Z0-9-_]") { #Validation Rule for computer names 24 | $ErrorProvider.SetError($GBComputerName, "Computer name invalid, please correct the computer name.") 25 | } else { 26 | $OSDComputerName = $TBComputerName.Text.ToUpper() 27 | $TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment 28 | $TSEnv.Value("OSDComputerName") = "$($OSDComputerName)" 29 | $Form.Close() 30 | } 31 | } 32 | 33 | [void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") 34 | [void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 35 | 36 | $Global:ErrorProvider = New-Object System.Windows.Forms.ErrorProvider 37 | 38 | $Form = New-Object System.Windows.Forms.Form 39 | $Form.Size = New-Object System.Drawing.Size(285,140) 40 | $Form.MinimumSize = New-Object System.Drawing.Size(285,140) 41 | $Form.MaximumSize = New-Object System.Drawing.Size(285,140) 42 | $Form.StartPosition = "CenterScreen" 43 | $Form.SizeGripStyle = "Hide" 44 | $Form.Text = "Enter Computer Name" 45 | $Form.ControlBox = $false 46 | $Form.TopMost = $true 47 | 48 | $TBComputerName = New-Object System.Windows.Forms.TextBox 49 | $TBComputerName.Location = New-Object System.Drawing.Size(25,30) 50 | $TBComputerName.Size = New-Object System.Drawing.Size(215,50) 51 | $TBComputerName.TabIndex = "1" 52 | 53 | $GBComputerName = New-Object System.Windows.Forms.GroupBox 54 | $GBComputerName.Location = New-Object System.Drawing.Size(20,10) 55 | $GBComputerName.Size = New-Object System.Drawing.Size(225,50) 56 | $GBComputerName.Text = "Computer name:" 57 | 58 | $ButtonOK = New-Object System.Windows.Forms.Button 59 | $ButtonOK.Location = New-Object System.Drawing.Size(195,70) 60 | $ButtonOK.Size = New-Object System.Drawing.Size(50,20) 61 | $ButtonOK.Text = "OK" 62 | $ButtonOK.TabIndex = "2" 63 | $ButtonOK.Add_Click({Set-OSDComputerName}) 64 | 65 | $Form.KeyPreview = $True 66 | $Form.Add_KeyDown({if ($_.KeyCode -eq "Enter"){Set-OSDComputerName}}) 67 | 68 | Load-Form -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/Set-WinPEWallpaper.ps1: -------------------------------------------------------------------------------- 1 | param( 2 | [Parameter(HelpMessage = 'Full path and name to the background picture file.')][string]$FilePath = 'X:\Windows\System32\WinPE.jpg', 3 | [Parameter(HelpMessage = 'Numeric file base name to the background picture file in the script path.')][int16]$ID 4 | ) 5 | If ($PSBoundParameters.ContainsKey('ID')) { 6 | #https://stackoverflow.com/questions/801967/how-can-i-find-the-source-path-of-an-executing-script/6985381#6985381 7 | #https://stackoverflow.com/questions/1183183/path-of-currently-executing-powershell-script 8 | #$Invocation = (Get-Variable MyInvocation -Scope 1).Value; #$ScriptPath = Split-Path $Invocation.MyCommand.Path 9 | #$ScriptPath = Split-Path -parent $PSCommandPath 10 | $ScriptPath = Split-Path -Path $script:MyInvocation.MyCommand.Path -Parent 11 | $IDFile = Join-Path -Path $ScriptPath -ChildPath $([string]$ID + '.jpg') 12 | If (Test-Path -Path $IDFile -PathType Leaf) { 13 | $FilePath = $IDFile 14 | } Else { 15 | Write-Error "File [$IDFile] was not found. Falling back to the default of [$FilePath]." 16 | } 17 | } 18 | 19 | $code = @' 20 | using System.Runtime.InteropServices; 21 | namespace Win32{ 22 | public class Wallpaper{ 23 | [DllImport("user32.dll", CharSet=CharSet.Auto)] 24 | static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ; 25 | // ---------------------------------------------------------- 26 | // FindWindow : http://msdn.microsoft.com/en-us/library/ms633499.aspx 27 | // ---------------------------------------------------------- 28 | [DllImport("user32.dll", SetLastError = true)] 29 | internal static extern int FindWindow(string lpClassName, string lpWindowName); 30 | // ---------------------------------------------------------- 31 | // Show Window : http://msdn.microsoft.com/en-us/library/ms633548.aspx 32 | // ---------------------------------------------------------- 33 | [DllImport("user32.dll", SetLastError = true)] 34 | internal static extern int ShowWindow(int hwnd, int nCmdShow); 35 | public static void SetWallpaper(string thePath){ 36 | SystemParametersInfo(20,0,thePath,3); 37 | // #################### 38 | // | Find Window 39 | // #################### 40 | int hwnd = FindWindow(null, "FirstUXWnd"); 41 | // #################### 42 | // | Hide Window : 0 = Hide, 1 = Show 43 | // #################### 44 | if (hwnd != 0) ShowWindow(hwnd, 0); 45 | } 46 | } 47 | } 48 | '@ 49 | add-type $code 50 | new-itemproperty -path "HKCU:\Control Panel\Desktop" -Name "WallpaperStyle" -PropertyType "String" -Value "3" -Force 51 | Write-Output "Setting Windows Desktop background to [$FilePath]." 52 | [Win32.Wallpaper]::SetWallpaper("$FilePath") -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/Start-VNC.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM wpeinit 3 | wpeutil DisableFirewall 4 | REM wpeutil InitializeNetwork 5 | winvnc.exe -install -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/Teardown.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Removes the temporary file created by SetupWinPEBoot.ps1 to fill an attached USB disk 4 | .DESCRIPTION 5 | Deletes directory {Drive:}\1EWSA\_dummy_stuff in all drives 6 | .LINK 7 | http://help.1e.com/display/WSS30/Scripts+for+Microsoft+VPN+client 8 | .NOTES 9 | Version: 1 10 | Author: Sravan Goud 11 | Creation Date: 03-05-2018 12 | Last Modified Date: 03-05-2018 13 | Purpose/Change: Initial script development 14 | #> 15 | $disks = Get-WMIObject -Class 'Win32_LogicalDisk' -Namespace 'root\CIMv2' 16 | ForEach ($disk in $disks) { 17 | $DummyFolder = Join-Path -Path $disk.DeviceID -ChildPath '\1EWSA\_dummy_stuff' 18 | If (Test-Path -Path $DummyFolder) { 19 | Remove-Item $DummyFolder -Force -Recurse 20 | } 21 | } -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/Test-PendingReboot.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | Created: 2014-01-08 3 | Version: 1.1 4 | Author Mikael Nystrom and Johan Arwidmark 5 | Homepage: http://www.deploymentfundamentals.com 6 | Credits: Brian Wilhite 7 | 8 | Disclaimer: 9 | This script is provided "AS IS" with no warranties, confers no rights and 10 | is not supported by the authors or DeploymentArtist. 11 | 12 | Author - Mikael Nystrom 13 | Twitter: @mikael_nystrom 14 | Blog : http://deploymentbunny.com 15 | 16 | Author - Johan Arwidmark 17 | Twitter: @jarwidmark 18 | Blog : http://deploymentresearch.com 19 | 20 | .LINK 21 | https://github.com/DeploymentResearch/DRFiles/blob/master/Scripts/Test-PendingReboot.ps1 22 | 23 | #> 24 | 25 | Function Check-PendingReboot{ 26 | 27 | $computername = $env:COMPUTERNAME 28 | 29 | # Connection to local or remote Registry 30 | $RegConnection = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"LocalMachine",$computername) 31 | 32 | # Query the Component Based Servicing Registry Key 33 | $RegSubKeysCBS = $RegConnection.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\").GetSubKeyNames() 34 | $CBSRebootPend = $RegSubKeysCBS -contains "RebootPending" 35 | 36 | # Query the Windows Update Auto Update Registry Key 37 | $RegWUAU = $RegConnection.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\") 38 | $RegWUAURebootReq = $RegWUAU.GetSubKeyNames() 39 | $WUAURebootReq = $RegWUAURebootReq -contains "RebootRequired" 40 | 41 | # Query the PendingFileRenameOperations Registry Key 42 | $RegSubKeySM = $RegConnection.OpenSubKey("SYSTEM\CurrentControlSet\Control\Session Manager\") 43 | $RegValuePFRO = $RegSubKeySM.GetValue("PendingFileRenameOperations",$null) 44 | 45 | # Closing registry connection 46 | $RegConnection.Close() 47 | 48 | # If PendingFileRenameOperations has a value set $RegValuePFRO variable to $true 49 | If ($RegValuePFRO) 50 | { 51 | $PendFileRename = $true 52 | 53 | } 54 | 55 | # Check if any of the variables are true 56 | If ($CBSRebootPend -or $WUAURebootReq -or $PendFileRename) 57 | { 58 | Write-Output "There is a pending reboot for $computername" 59 | Write-Output "Please reboot $computername" 60 | } 61 | 62 | Else 63 | { 64 | Write-Output "No reboot is pending for $computername" 65 | 66 | } 67 | } 68 | . Check-PendingReboot -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/TsProgressUI.exe.stub: -------------------------------------------------------------------------------- 1 | stub file to be replaced with real file -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/Write-TSVariables.ps1.stub: -------------------------------------------------------------------------------- 1 | stub file to be replaced with real file -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/config.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Tools/devcon.exe.stub: -------------------------------------------------------------------------------- 1 | stub file to be replaced with real file -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Windows/7za.exe.stub: -------------------------------------------------------------------------------- 1 | stub file to be replaced with real file -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Windows/Clean-Disk0.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo !!!!! WARNING !!!!! This will erase your hard drive !!!!! WARNING !!!!! 3 | echo Press CTRL+C to abort or 4 | pause 5 | echo select disk 0 > x:\Clean-Disk0.txt 6 | echo clean >> x:\Clean-Disk0.txt 7 | if exist x:\Clean-Disk0.txt diskpart /s x:\Clean-Disk0.txt -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Windows/Enable-RemoteSupport.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | If /I "[%1]"=="/h" Goto:about 4 | If /I "[%1]"=="/help" Goto:about 5 | goto:Begin 6 | :about 7 | echo =========================================================================================== 8 | echo .Synopsis 9 | echo Enable Remote Support 10 | echo .Description 11 | echo Add exceptions to the Windows Firewall for ICMP v4 (Ping) 12 | echo Add exceptions to the Windows Firewall for Remote Administration (WinRM, RDP, File and Printer Sharing) 13 | echo Add exceptions to the Windows Firewall for VNC 14 | echo Configure WinRM 15 | echo Disable the Windows Firewall 16 | echo. 17 | echo Not all commands work in WinPE or Windows. Some errors are expected. 18 | echo .Parameters 19 | echo [/h] [/help] display this help information 20 | echo .Notes 21 | echo === Change Log History === 22 | echo 2015/08/27 by Chad.Simmons@CatapultSystems.com - Created 23 | echo =========================================================================================== 24 | goto:eof 25 | 26 | :Begin 27 | echo Enable ICMP (ping) 28 | netsh advfirewall firewall set rule name="File and Printer Sharing (Echo Request - ICMPv4-In)" new enable=Yes 29 | 30 | echo Enable RDP 31 | netsh advfirewall firewall set rule group="Remote Desktop" new enable=Yes 32 | 33 | echo Enable Remote Administrator 34 | netsh advfirewall firewall set rule group="remote administration" new enable=yes 35 | 36 | echo Enable VNC 37 | netsh advfirewall firewall add rule name="VNC (TCP-in)" dir=in action=allow protocol=TCP localport=5900 38 | 39 | echo Disable Windows Firewall 40 | netsh advfirewall set allprofiles state off 41 | wpeutil DisableFirewall 42 | 43 | echo Enable WinRM for Remote access 44 | winrm quickconfig -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Windows/Get-ComputerName.cmd: -------------------------------------------------------------------------------- 1 | @Echo off 2 | :: Ping %1 3 | :: Get IP from Ping 4 | :: Get ComputerName from registry of IP 5 | :: Get ComputerName from ping -a 6 | :: Get ComputerName from NBTStat -a IP 7 | 8 | Ping -a %1 9 | pause 10 | reg query \\%1\HKLM\System\CurrentControlSet\Control\ComputerName\ActiveComputerName /v ComputerName 11 | nbtstat -a %1 -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Windows/Get-SMSTSLog.cmd: -------------------------------------------------------------------------------- 1 | @Echo Off 2 | If /I "%1"=="/?" Goto:about 3 | If /I "%1"=="/h" Goto:about 4 | If /I "%1"=="/help" Goto:about 5 | Goto:Main 6 | :about 7 | echo =========================================================================================== 8 | echo .Synopsis 9 | echo Open SMSTS.log from any of its standard locations with CMTrace 10 | echo.ChangeLog 11 | echo 2014/08/15 - Chad.Simmons@CatapultSystems.com OR chad@ChadsTech.net - created 12 | echo =========================================================================================== 13 | echo 14 | goto:eof 15 | 16 | :main 17 | 18 | :ConfigureCMTrace 19 | ::re-register CMTrace so it does not prompt to always open log files in itself 20 | reg.exe add HKCU\Software\Microsoft\Trace32 /V "Register File Types" /T REG_SZ /D 1 /F 21 | ::set CMTrace preferences 22 | reg.exe add HKCU\Software\Microsoft\Trace32 /V Column0 /T REG_SZ /D "2 125" /F 23 | reg.exe add HKCU\Software\Microsoft\Trace32 /V Column1 /T REG_SZ /D "1 90" /F 24 | reg.exe add HKCU\Software\Microsoft\Trace32 /V Column2 /T REG_SZ /D "0 1000" /F 25 | reg.exe add HKCU\Software\Microsoft\Trace32 /V Column3 /T REG_SZ /D "3 0" /F 26 | reg.exe add HKCU\Software\Microsoft\Trace32 /V ColumnState /T REG_SZ /D 4 /F 27 | 28 | :GetLogTool 29 | If Exist X:\Windows\System32\CMTrace.exe set LogTool=X:\Windows\System32\CMTrace.exe 30 | If Exist X:\Windows\CMTrace.exe set LogTool=X:\Windows\CMTrace.exe 31 | If Exist X:\Tools\CMTrace.exe set LogTool=X:\Tools\CMTrace.exe 32 | If Exist %~dp0CMTrace.exe set LogTool=%~dp0CMTrace.exe 33 | 34 | :OpenSMSTSLog 35 | If Exist X:\Windows\Temp\SMSTSLog\SMSTS.log start %LogTool% X:\Windows\Temp\SMSTSLog\SMSTS.log 36 | If Exist C:\_SMSTaskSequence\Logs\SMSTSLog\SMSTS.log start %LogTool% C:\_SMSTaskSequence\Logs\SMSTSLog\SMSTS.log 37 | If Exist D:\_SMSTaskSequence\Logs\SMSTSLog\SMSTS.log start %LogTool% D:\_SMSTaskSequence\Logs\SMSTSLog\SMSTS.log 38 | If Exist E:\_SMSTaskSequence\Logs\SMSTSLog\SMSTS.log start %LogTool% E:\_SMSTaskSequence\Logs\SMSTSLog\SMSTS.log 39 | If Exist %WinDir%\CCM\Logs\SMSTSLog\SMSTS.log start %LogTool% %WinDir%\CCM\Logs\SMSTSLog\SMSTS.log 40 | If Exist %WinDir%\sysWOW6432\CCM\Logs\SMSTSLog\SMSTS.log start %LogTool% %WinDir%\sysWOW6432\CCM\Logs\SMSTSLog\SMSTS.log 41 | If Exist %WinDir%\CCM\Logs\SMSTS.log start %LogTool% %WinDir%\CCM\Logs\SMSTS.log 42 | If Exist %WinDir%\sysWOW6432\CCM\Logs\SMSTS.log start %LogTool% %WinDir%\sysWOW6432\CCM\Logs\SMSTS.log 43 | 44 | :eof -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Windows/Get-ScreenShot.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | If /I "[%1]"=="/h" Goto:about 4 | If /I "[%1]"=="/help" Goto:about 5 | goto:Begin 6 | :about 7 | echo =========================================================================================== 8 | echo .Synopsis 9 | echo Take a Screenshot 10 | echo .Description 11 | echo If Greenshot is found, use it as the screen capture tool. 12 | echo Note: this only works with Windows 32-bit or Windows On Windows. WinPE x64 does not support WoW. 13 | echo If Greenshot is not found, find Zoomit and use it as the screen capture tool. 14 | echo .Parameters 15 | echo [/h] [/help] display this help information 16 | echo .Notes 17 | echo === Keywords === 18 | echo screenshot, screen shot, screen capture, zoomit, greenshot 19 | echo === References === 20 | echo http://deploymentresearch.com/Research/Post/472/Quick-Tip-Use-ZoomIt-to-take-a-screenshot-in-WinPE 21 | echo === Change Log History === 22 | echo 2015/08/28 by Chad.Simmons@CatapultSystems.com - Created 23 | echo =========================================================================================== 24 | goto:eof 25 | 26 | 27 | :FindZoomIt 28 | ::If Greenshot is found use it, otherwise attempt to find ZoomIt 29 | If Exist %~dp0GreenShot.exe set myTool=%~dp0GreenShot.exe 30 | If NOT Defined myTool ( 31 | If Exist \Tools\GreenShot\GreenShot.exe set myTool=\Tools\GreenShot\GreenShot.exe 32 | ) 33 | If NOT Defined myTool ( 34 | If Exist \Tools\x86\GreenShot.exe set myTool=\Tools\x86\GreenShot.exe 35 | ) 36 | If NOT Defined myTool ( 37 | If Exist %~dp0ZoomIt.exe set myTool=%~dp0ZoomIt.exe 38 | ) 39 | If NOT Defined myTool ( 40 | If Exist \Tools\ZoomIt.exe set myTool=\Tools\ZoomIt.exe 41 | ) 42 | If NOT Defined myTool ( 43 | If Exist \Tools\x64\ZoomIt.exe set myTool=\Tools\x64\ZoomIt.exe 44 | ) 45 | If NOT Defined myTool ( 46 | If Exist \Tools\x86\ZoomIt.exe set myTool=\Tools\x86\ZoomIt.exe 47 | ) 48 | 49 | If NOT Defined myTool goto:ToolNotFound 50 | 51 | :AcceptTheLicense 52 | reg.exe ADD HCU\Software\Sysinternals\Zoomit /d EulaAccepted /v 0 /t REG_DW /f 53 | 54 | Echo To perform a screenshot with ZoomIt 55 | Echo 1. Press CTRL+2 which will activate ZoomIt without zooming 56 | Echo 2. Press CTROL+S to save the screen to a location that you specify 57 | Echo. 58 | Echo To perform a screenshot with Greenshot 59 | Echo 1. Press PrintScreen 60 | Echo. 61 | %myTool% 62 | 63 | 64 | goto:eof 65 | :ToolNotFound 66 | echo "The screen shot / screen capture utility was not found 67 | goto:eof 68 | 69 | 70 | 71 | 72 | :eof -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Windows/Get-TSVars.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | If /I "[%1]"=="/h" Goto:about 4 | If /I "[%1]"=="/help" Goto:about 5 | goto:Begin 6 | :about 7 | echo =========================================================================================== 8 | echo .Synopsis 9 | echo Export MDT/SCCM Task Sequence Variables to a file and open the output with CMTrace 10 | echo .Description 11 | echo .Parameters 12 | echo [/h] [/help] display this help information 13 | echo .Notes 14 | echo === Keywords === 15 | echo screenshot, screen shot, screen capture, zoomit, greenshot 16 | echo === References === 17 | echo http://deploymentresearch.com/Research/Post/472/Quick-Tip-Use-ZoomIt-to-take-a-screenshot-in-WinPE 18 | echo === Change Log History === 19 | echo 2014/09/19 by Chad.Simmons@CatapultSystems.com OR chad@ChadsTech.net - Created 20 | echo =========================================================================================== 21 | goto:eof 22 | 23 | :Begin 24 | setlocal 25 | set customScripts=%SystemDrive%\Tools\Scripts 26 | 27 | :ConfigureCMTrace 28 | ::re-register CMTrace so it does not prompt to always open log files in itself 29 | reg.exe add HKCU\Software\Microsoft\Trace32 /V "Register File Types" /T REG_SZ /D 1 /F 30 | ::set CMTrace preferences 31 | reg.exe add HKCU\Software\Microsoft\Trace32 /V Column0 /T REG_SZ /D "2 125" /F 32 | reg.exe add HKCU\Software\Microsoft\Trace32 /V Column1 /T REG_SZ /D "1 170" /F 33 | reg.exe add HKCU\Software\Microsoft\Trace32 /V Column2 /T REG_SZ /D "0 1000" /F 34 | reg.exe add HKCU\Software\Microsoft\Trace32 /V Column3 /T REG_SZ /D "3 0" /F 35 | reg.exe add HKCU\Software\Microsoft\Trace32 /V ColumnState /T REG_SZ /D 4 /F 36 | 37 | :GetLogTool 38 | If Exist %SystemDrive%\Windows\System32\CMTrace.exe set LogTool=%SystemDrive%\Windows\System32\CMTrace.exe 39 | If Exist %SystemDrive%\Windows\CMTrace.exe set LogTool=%SystemDrive%\Windows\CMTrace.exe 40 | If Exist %SystemDrive%\Tools\CMTrace.exe set LogTool=%SystemDrive%\Tools\CMTrace.exe 41 | If Exist %~dp0CMTrace.exe set LogTool=%~dp0CMTrace.exe 42 | 43 | :OpenSMSTSLog 44 | :PS1 45 | If NOT Exist %customScripts%\OutputTSVariables.ps1 goto:VBS 46 | Set PSexe=%SystemDrive%\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe 47 | If NOT Exist %PSexe% goto:VBS 48 | %PSexe% -ExecutionPolicy Bypass -file "%customScripts%\OutputTSVariables.ps1" 49 | echo . 50 | echo . 51 | echo execute "%LogTool% %SystemDrive%\Windows\Temp\SMSTSLog\OutputTSVariables.ps1.log" to view this version of the file. 52 | echo . 53 | echo . 54 | 55 | :VBS 56 | If NOT Exist %customScripts%\OutputTSVariables.vbs goto:WSF 57 | echo Exporting Task Sequence Variables using OutputTSVariables.vbs to %SystemDrive%\TSVars.log ... 58 | if Exist %SystemDrive%\TSVars.log del %SystemDrive%\TSVars.log 59 | cscript.exe /nologo "%customScripts%\OutputTSVariables.vbs" > %SystemDrive%\TSVars.log 60 | start %LogTool% %SystemDrive%\TSVars.log 61 | 62 | :WSF 63 | If NOT Exist %customScripts%\OutputTSVariables.wsf goto:END 64 | echo Exporting Task Sequence Variables using OutputTSVariables.wsf to %SystemDrive%\TSVars.txt ... 65 | If Exist %SystemDrive%\TSVars.txt del %SystemDrive%\TSVars.txt 66 | cscript.exe /nologo "%customScripts%\OutputTSVariables.wsf" > %SystemDrive%\TSVars.txt 67 | echo . 68 | echo . 69 | echo execute "%LogTool% %SystemDrive%\TSVars.txt" to view this version of the file. 70 | echo . 71 | echo . 72 | 73 | :END 74 | 75 | :EOF -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Windows/SMSTS.ini: -------------------------------------------------------------------------------- 1 | ;This file must be injected into the Windows directory of the WinPE boot media manually or by editing osdinjection.xml 2 | [Logging] 3 | LOGMAXSIZE=52428800 4 | ; 5242880 (5MB): default 5 | LOGMAXHISTORY=3 6 | ; 3: default 7 | DEBUGLOGGING=1 8 | ;CCMDEBUGLOGGING=1 9 | ; 0: Turn off debug logging (default) 10 | ; 1: Turn on debug logging 11 | ;LOGLEVEL=0 12 | ; 0: Verbose 13 | ; 1: Default 14 | ; 2: Warnings and errors 15 | ; 3: Errors only 16 | ; 17 | ;In the Task Sequence step "Setup Windows and ConfigMgr" add Installation Properties similar to "CCMMAXLOGSIZE=524288000 CCMLOGLEVEL=0 CCMMAXLOGHISTORY=9 CCMDEBUGLOGGING=1" 18 | ;References 19 | ;https://techcommunity.microsoft.com/t5/configuration-manager-archive/how-to-change-logging-options-for-smsts-log-in-system-center/ba-p/392236 20 | ;https://learn.microsoft.com/en-us/mem/configmgr/core/clients/deploy/about-client-installation-properties 21 | ;http://deploymentresearch.com/Research/Post/537/Understanding-logging-in-ConfigMgr-OS-Deployment 22 | ;http://www.niallbrady.com/wp-content/uploads/2013/10/smsts.ini_.txt 23 | -------------------------------------------------------------------------------- /ConfigMgr/OSD WinPE Extra Files/x64/Windows/Set-OneNICActive.cmd: -------------------------------------------------------------------------------- 1 | @Echo Off 2 | If /I "%1"=="/?" Goto:about 3 | If /I "%1"=="/h" Goto:about 4 | If /I "%1"=="/help" Goto:about 5 | Goto:Main 6 | :about 7 | echo =========================================================================================== 8 | echo .Synopsis 9 | echo Disable all but 1 NIC and configure static IP settings 10 | echo .Description 11 | echo list all NICs, disable all NICs, enable 1 NIC, use netsh to set statis IP and DNS, use reg.exe to set DNSsuffixes 12 | echo .ChangeLog 13 | echo 2014/07/31 by Chad.Simmons@CatapultSystems.com - Created 14 | echo .Link 15 | echo http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/enabledisable-network-interface-via-command-line/17a21634-c5dd-4038-bc0a-d739209f5081 16 | echo http://slecluyse.wordpress.com/2010/08/18/enable-or-disable%C2%A0nics 17 | echo http://www.petri.com/configure_tcp_ip_from_cmd.htm 18 | echo http://support.microsoft.com/kb/275553 19 | echo Netsh commands for Interface IP http://technet.microsoft.com/en-us/library/bb490943.aspx 20 | echo =========================================================================================== 21 | 22 | :main 23 | setlocal 24 | 25 | ::list all nics 26 | WMIC NIC get Name, Index, NetConnectionID 27 | 28 | echo enter the NetConnectionID of the NIC which should be enabled 29 | set /p ActiveNIC= 30 | 31 | Echo Disabling all NICs 32 | wmic path win32_networkadapter where "NetConnectionID like '%%'" call disable 33 | Echo Enable 1 NIC 34 | wmic path win32_networkadapter where "NetConnectionID = '%ActiveNIC%'" call enable 35 | 36 | echo Press CTRL+C to abort or 37 | echo Enter the desired STATIC IP 38 | set /p StaticIP= 39 | echo Enter the desired STATIC Default Gateway 40 | set /p Gateway= 41 | echo Enter the desired STATIC Subnet Mask 42 | set /p Mask= 43 | echo Enter the desired STATIC DNS Server IP 44 | set /p DNSIP= 45 | echo Enter the desired STATIC Primary DNS suffix 46 | set /p DNSsuffix= 47 | echo Enter the desired STATIC Additional DNS suffixes (comma seperated) 48 | set /p DNSsuffix2= 49 | 50 | netsh interface IP set address name="%ActiveNIC%" source=static addr=%StaticIP% mask=%Mask% gateway=%Gateway% 51 | netsh interface IP set dns name="%ActiveNIC%" source=static addr=%DNSIP% 52 | reg.exe add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v "NV Domain" /d "%DNSsuffix%" /f 53 | reg.exe add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v "SearchList" /d "%DNSsuffix%,%DNSsuffix2%" /f 54 | 55 | ipconfig /all -------------------------------------------------------------------------------- /ConfigMgr/Operations/Add-MCMUpdateToPackage.ps1: -------------------------------------------------------------------------------- 1 | param ( 2 | [string]$DeploymentPackage, 3 | [string]$SoftwareUpdateGroup, 4 | [string]$SiteCode, 5 | [string]$SiteServer 6 | ) 7 | 8 | #Function to download updates from the specified URL to the specified path 9 | function Get-Update { 10 | param ( 11 | [string]$URL, 12 | [string]$Path 13 | ) 14 | $File = Split-Path -Leaf $URL 15 | $FilePath = "$Path\$File" 16 | 17 | try { 18 | "Started downloading from [$URL]" 19 | $WebClient = New-Object System.Net.WebClient 20 | $WebClient.DownloadFile($URL, $FilePath) 21 | "Finished downloading to [$FilePath]" 22 | } 23 | catch { 24 | "Failed to download from [$URL]" 25 | "Error: $_" 26 | } 27 | } 28 | 29 | #Function to add update content to a deployment package 30 | function Add-UpdateContent { 31 | param ( 32 | [string]$DeploymentPackage, 33 | [array]$UpdateContentIDs, 34 | [array]$UpdateContentSourcePaths 35 | ) 36 | try { 37 | $PackageID = (Get-WmiObject -Namespace root/SMS/site_$($SiteCode) -ComputerName $SiteServer -Query "SELECT * FROM SMS_SoftwareUpdatesPackage WHERE Name='$DeploymentPackage'").PackageID 38 | Invoke-WmiMethod -Path "\\$($SiteServer)\root\sms\site_$($SiteCode):SMS_SoftwareUpdatesPackage.PackageID='$PackageID'" -Name AddUpdateContent -ArgumentList @($false,$UpdateContentIDs,$UpdateContentSourcePaths) 39 | "Added content to the deployment package." 40 | } 41 | catch { 42 | "Failed to add content to the deployment package." 43 | "Error: $_" 44 | } 45 | } 46 | 47 | $TempDownloadPath = "C:\Temp" #Set temporary download location 48 | New-Item -Path $TempDownloadPath -ItemType Directory #Create temporary download location 49 | 50 | $UpdateContentIDs = @() #Create empty array for the update content IDs 51 | $UpdateContentSourcePaths = @() #Create empty arrays for the update content source path 52 | $UpdateGroupCIID = (Get-WmiObject -Namespace root/SMS/site_$($SiteCode) -ComputerName $SiteServer -Query "SELECT * FROM SMS_AuthorizationList WHERE LocalizedDisplayName='$SoftwareUpdateGroup'").CI_ID #Get the CI ID of the software update group 53 | $Updates = Get-WmiObject -Namespace root/SMS/site_$($SiteCode) -ComputerName $SiteServer -Query "SELECT upd.* FROM SMS_SoftwareUpdate upd, SMS_CIRelation cr WHERE cr.FromCIID='$UpdateGroupCIID' AND cr.RelationType=1 AND upd.IsContentProvisioned=0 AND upd.CI_ID=cr.ToCIID" #Get the updates that are member of the software update group via the CI ID 54 | foreach ($Update in $Updates) { #Foreach update find the content location and download the content 55 | $UpdateCIID = $Update.CI_ID 56 | $UpdateContent = Get-WmiObject -Namespace root/SMS/site_$($SiteCode) -ComputerName $SiteServer -Query "SELECT fil.* FROM SMS_CIToContent con, SMS_CIContentFiles fil WHERE con.CI_ID='$UpdateCIID' AND con.ContentID=fil.ContentID" #Get the content information of the software updates CI ID 57 | foreach ($Content in $UpdateContent) { #Foreach content of the update, download the content 58 | Get-Update $Content.SourceURL $TempDownloadPath #Download the content to the temporary download location 59 | $UpdateContentIDs += $Content.ContentID #Store the content ID 60 | $UpdateContentSourcePaths += $TempDownloadPath #Store the temporary download location 61 | } 62 | } 63 | 64 | Add-UpdateContent $DeploymentPackage $UpdateContentIDs $UpdateContentSourcePaths #Add updates from the temporary location to the deployment package 65 | Remove-Item $TempDownloadPath -Force -Recurse #Remove temporary download location -------------------------------------------------------------------------------- /ConfigMgr/Operations/Cancel-MCMPendingReboot.ps1: -------------------------------------------------------------------------------- 1 | # Cancel-MCMPendingReboot.ps1 2 | # Cancel a ConfigMgr pending reboot 3 | # https://sccmf12twice.com/sccm-reboot-decoded-how-to-make-a-pc-cancel-start-extend-or-change-mandatory-reboot-to-non-mandatory-on-the-fly 4 | Remove-Item -path 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData'; 5 | Remove-Item -path 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Updates Management\Handler\UpdatesRebootStatus\*'; 6 | Remove-ItemProperty -name * -path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'; 7 | #on PS2.0, "Remove-ItemProperty" doesn't work, so use this. #Remove-Item -path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired'; 8 | Shutdown.exe -a 9 | Restart-Service -Force -Name CCMEXEC, WUAUSERV 10 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/Collection Management/Clear-CollectionMembership.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/Collection Management/Clear-CollectionMembership.ps1 -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Install ConfigMgr Client.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Install ConfigMgr Client.html -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Manage BITS on WinXP_2003.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Manage BITS on WinXP_2003.html -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Manage BITS.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Manage BITS.html -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Manage ConfigMgr Client.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Manage ConfigMgr Client.html -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Manage Win10 Delivery Optimization.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Manage Win10 Delivery Optimization.html -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Manage WinRM.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Manage WinRM.html -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Manage Windows Update Agent.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/Manage Windows Update Agent.html -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{349C7B9E-6740-4519-B65E-F6D9BC8EC8AF}/DomainSysvol/GPO/Adm/configmgrassignment.adm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{349C7B9E-6740-4519-B65E-F6D9BC8EC8AF}/DomainSysvol/GPO/Adm/configmgrassignment.adm -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{349C7B9E-6740-4519-B65E-F6D9BC8EC8AF}/DomainSysvol/GPO/Adm/configmgrinstallation.adm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{349C7B9E-6740-4519-B65E-F6D9BC8EC8AF}/DomainSysvol/GPO/Adm/configmgrinstallation.adm -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{349C7B9E-6740-4519-B65E-F6D9BC8EC8AF}/DomainSysvol/GPO/Machine/Applications/{2BDD37FE-E5E6-48F1-98E3-75EA91C7AFD9}.aas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{349C7B9E-6740-4519-B65E-F6D9BC8EC8AF}/DomainSysvol/GPO/Machine/Applications/{2BDD37FE-E5E6-48F1-98E3-75EA91C7AFD9}.aas -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{349C7B9E-6740-4519-B65E-F6D9BC8EC8AF}/DomainSysvol/GPO/Machine/registry.pol: -------------------------------------------------------------------------------- 1 | PReg[Software\Microsoft\SMS\Mobile Client;GPRequestedSiteAssignmentCode;;;LAB][Software\Microsoft\SMS\Mobile Client;GPSiteAssignmentRetryInterval(Min);;;-][Software\Microsoft\SMS\Mobile Client;GPSiteAssignmentRetryDuration(Hour);;;H][Software\Policies\Microsoft\ccmsetup;NoDefAutoAssign;;;][Software\Policies\Microsoft\ccmsetup;SetupParameters;;;/logon /mp:ConfigMgrMP.contoso.com SMSSITECODE=LAB SMSMP=ConfigMgrMP.contoso.com FSP=ConfigMgrFSP.contoso.com DNSSUFIX=contoso.com] -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{349C7B9E-6740-4519-B65E-F6D9BC8EC8AF}/bkupInfo.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{349C7B9E-6740-4519-B65E-F6D9BC8EC8AF}/gpreport.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{349C7B9E-6740-4519-B65E-F6D9BC8EC8AF}/gpreport.xml -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{4B518C3A-10E9-4CF2-995E-9273B182D86F}/DomainSysvol/GPO/Machine/comment.cmtx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{4B518C3A-10E9-4CF2-995E-9273B182D86F}/DomainSysvol/GPO/Machine/microsoft/windows nt/SecEdit/GptTmpl.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{4B518C3A-10E9-4CF2-995E-9273B182D86F}/DomainSysvol/GPO/Machine/microsoft/windows nt/SecEdit/GptTmpl.inf -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{4B518C3A-10E9-4CF2-995E-9273B182D86F}/DomainSysvol/GPO/Machine/registry.pol: -------------------------------------------------------------------------------- 1 | PReg[Software\Policies\Microsoft\Windows\WinRM\Service;AllowAutoConfig;;;][Software\Policies\Microsoft\Windows\WinRM\Service;IPv4Filter;;;*][Software\Policies\Microsoft\Windows\WinRM\Service;IPv6Filter;;;*][Software\Policies\Microsoft\WindowsFirewall;PolicyVersion;;;][Software\Policies\Microsoft\WindowsFirewall\FirewallRules;WINRM-HTTP-In-TCP;;f;v2.20|Action=Allow|Active=TRUE|Dir=In|Protocol=6|Profile=Domain|LPort=5985|App=System|Name=@FirewallAPI.dll,-30253|Desc=@FirewallAPI.dll,-30256|EmbedCtxt=@FirewallAPI.dll,-30267|] -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{4B518C3A-10E9-4CF2-995E-9273B182D86F}/bkupInfo.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{4B518C3A-10E9-4CF2-995E-9273B182D86F}/gpreport.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{4B518C3A-10E9-4CF2-995E-9273B182D86F}/gpreport.xml -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{5D14D390-ACB2-41B6-85DA-2E8C56203BDC}/DomainSysvol/GPO/Machine/comment.cmtx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | MUST be Not Configured 15 | (optional) Set to Enabled for ConfigMgr environments. https://blogs.technet.microsoft.com/windowsserver/2017/01/09/why-wsus-and-sccm-managed-clients-are-reaching-out-to-microsoft-online 16 | 17 | 18 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{5D14D390-ACB2-41B6-85DA-2E8C56203BDC}/DomainSysvol/GPO/Machine/microsoft/windows nt/SecEdit/GptTmpl.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{5D14D390-ACB2-41B6-85DA-2E8C56203BDC}/DomainSysvol/GPO/Machine/microsoft/windows nt/SecEdit/GptTmpl.inf -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{5D14D390-ACB2-41B6-85DA-2E8C56203BDC}/DomainSysvol/GPO/Machine/registry.pol: -------------------------------------------------------------------------------- 1 | PReg[Software\Policies\Microsoft\Windows\WindowsUpdate;AcceptTrustedPublisherCerts;;;][Software\Policies\Microsoft\Windows\WindowsUpdate;DoNotConnectToWindowsUpdateInternetLocations;;;][Software\Policies\Microsoft\Windows\WindowsUpdate\AU;NoAutoUpdate;;;][Software\Policies\Microsoft\Windows\WindowsUpdate\AU;**del.AUOptions;;; ][Software\Policies\Microsoft\Windows\WindowsUpdate\AU;**del.AutomaticMaintenanceEnabled;;; ][Software\Policies\Microsoft\Windows\WindowsUpdate\AU;**del.ScheduledInstallDay;;; ][Software\Policies\Microsoft\Windows\WindowsUpdate\AU;**del.ScheduledInstallTime;;; ] -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{5D14D390-ACB2-41B6-85DA-2E8C56203BDC}/bkupInfo.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{5D14D390-ACB2-41B6-85DA-2E8C56203BDC}/gpreport.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{5D14D390-ACB2-41B6-85DA-2E8C56203BDC}/gpreport.xml -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{74917769-439E-4C57-9872-EDA53C9ECA9D}/DomainSysvol/GPO/Machine/Preferences/Files/Files.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{74917769-439E-4C57-9872-EDA53C9ECA9D}/DomainSysvol/GPO/Machine/Preferences/Folders/Folders.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{74917769-439E-4C57-9872-EDA53C9ECA9D}/DomainSysvol/GPO/Machine/Preferences/ScheduledTasks/ScheduledTasks.xml: -------------------------------------------------------------------------------- 1 | 2 | LAB\AdminNT AUTHORITY\SystemS4UHighestAvailablePT5MPT1HfalsefalseIgnoreNewfalsefalsetruetruetruefalsePT1H7PT5M32017-06-05T12:05:00true1PT30MPT30M 3 | PowerShell.exe-ExecutionPolicy Bypass -NoProfile -Noninteractive -File "\\DFSNamespace_or_Server\Share\ConfigMgrClientHealth.ps1" -Config "\\DFSNamespace_or_Server\Share\Config.xml" 4 | 5 | 6 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{74917769-439E-4C57-9872-EDA53C9ECA9D}/DomainSysvol/GPO/Machine/Scripts/scripts.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{74917769-439E-4C57-9872-EDA53C9ECA9D}/DomainSysvol/GPO/Machine/Scripts/scripts.ini -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{74917769-439E-4C57-9872-EDA53C9ECA9D}/DomainSysvol/GPO/Machine/microsoft/windows nt/SecEdit/GptTmpl.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{74917769-439E-4C57-9872-EDA53C9ECA9D}/DomainSysvol/GPO/Machine/microsoft/windows nt/SecEdit/GptTmpl.inf -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{74917769-439E-4C57-9872-EDA53C9ECA9D}/DomainSysvol/GPO/Machine/registry.pol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{74917769-439E-4C57-9872-EDA53C9ECA9D}/DomainSysvol/GPO/Machine/registry.pol -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{74917769-439E-4C57-9872-EDA53C9ECA9D}/bkupInfo.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{74917769-439E-4C57-9872-EDA53C9ECA9D}/gpreport.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{74917769-439E-4C57-9872-EDA53C9ECA9D}/gpreport.xml -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ACA769E3-6C81-414A-B71B-8136A4A22311}/DomainSysvol/GPO/Machine/comment.cmtx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Generally set to Not Configured 14 | 15 | 16 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ACA769E3-6C81-414A-B71B-8136A4A22311}/DomainSysvol/GPO/Machine/microsoft/windows nt/SecEdit/GptTmpl.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ACA769E3-6C81-414A-B71B-8136A4A22311}/DomainSysvol/GPO/Machine/microsoft/windows nt/SecEdit/GptTmpl.inf -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ACA769E3-6C81-414A-B71B-8136A4A22311}/DomainSysvol/GPO/Machine/registry.pol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ACA769E3-6C81-414A-B71B-8136A4A22311}/DomainSysvol/GPO/Machine/registry.pol -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ACA769E3-6C81-414A-B71B-8136A4A22311}/bkupInfo.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ACA769E3-6C81-414A-B71B-8136A4A22311}/gpreport.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ACA769E3-6C81-414A-B71B-8136A4A22311}/gpreport.xml -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{D7A8AF60-1697-4155-8CAC-A91DF02120D6}/DomainSysvol/GPO/Machine/Microsoft/Windows NT/SecEdit/GptTmpl.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{D7A8AF60-1697-4155-8CAC-A91DF02120D6}/DomainSysvol/GPO/Machine/Microsoft/Windows NT/SecEdit/GptTmpl.inf -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{D7A8AF60-1697-4155-8CAC-A91DF02120D6}/DomainSysvol/GPO/Machine/comment.cmtx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | https://blogs.technet.microsoft.com/mniehaus/2016/08/16/windows-10-delivery-optimization-and-wsus-take-2 and https://docs.microsoft.com/en-us/windows/deployment/update/waas-optimize-windows-10-updates 17 | (optional) configure per ConfiMgr Boundary Group where a local Distribution Point exists 18 | Set to 0 to make the cache semi-permanent https://docs.microsoft.com/en-us/windows/deployment/update/waas-delivery-optimization#set-preferred-cache-devices-for-delivery-optimization 19 | Set to <=64 to effectively disable Internet traffic. https://docs.microsoft.com/en-us/windows/deployment/update/waas-delivery-optimization#set-preferred-cache-devices-for-delivery-optimization 20 | 21 | 22 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{D7A8AF60-1697-4155-8CAC-A91DF02120D6}/DomainSysvol/GPO/Machine/registry.pol: -------------------------------------------------------------------------------- 1 | PReg[SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization;DODownloadMode;;;d] -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{D7A8AF60-1697-4155-8CAC-A91DF02120D6}/bkupInfo.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{D7A8AF60-1697-4155-8CAC-A91DF02120D6}/gpreport.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{D7A8AF60-1697-4155-8CAC-A91DF02120D6}/gpreport.xml -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ECFF29C7-53CD-4E92-AC67-8CEB50621CC1}/DomainSysvol/GPO/Machine/comment.cmtx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Do NOT set on Windows 7 and newer 15 | Generally set to Not Configured 16 | 17 | 18 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ECFF29C7-53CD-4E92-AC67-8CEB50621CC1}/DomainSysvol/GPO/Machine/microsoft/windows nt/SecEdit/GptTmpl.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ECFF29C7-53CD-4E92-AC67-8CEB50621CC1}/DomainSysvol/GPO/Machine/microsoft/windows nt/SecEdit/GptTmpl.inf -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ECFF29C7-53CD-4E92-AC67-8CEB50621CC1}/DomainSysvol/GPO/Machine/registry.pol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ECFF29C7-53CD-4E92-AC67-8CEB50621CC1}/DomainSysvol/GPO/Machine/registry.pol -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ECFF29C7-53CD-4E92-AC67-8CEB50621CC1}/bkupInfo.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ECFF29C7-53CD-4E92-AC67-8CEB50621CC1}/gpreport.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Operations/ConfigMgr GPO examples/ConfigMgr GPOs/{ECFF29C7-53CD-4E92-AC67-8CEB50621CC1}/gpreport.xml -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/Netlogon/CCMSetup/ccmsetup.msi.stub: -------------------------------------------------------------------------------- 1 | Stub file to be replaced by the actual file -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/Netlogon/CCMtools/ConfigMgrStartup-WMI.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | \\cm1\client\i386\hotfix\05-KB2276865\sccm2007ac-sp2-kb2276865-x86.msp 19 | \\cm1\client\i386\hotfix\09-KB2509007\sccm2007ac-sp2-kb2509007-x86-enu.msp 20 | HIGH 21 | \\cm1\Client 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/Netlogon/CCMtools/ConfigMgrStartup.custom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | \cm1\ConfigMgr\Client\Install It 14 | HIGH 15 | 16 | 17 | cm1.lab.local 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/Netlogon/CCMtools/ConfigMgrStartup.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | HIGH 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/ConfigMgr GPO examples/Netlogon/CCMtools/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5.00.8498.1007 4 | CEN 5 | lab.net 6 | True 7 | 8192 8 | \\SCCM.lab.net\Clienthealth$\Client 9 | 10 | SMSSITECODE=CEN 11 | MP=SCCM.LAB.NET 12 | FSP=SCCM.LAB.NET 13 | DNSSUFFIX=LAB.NET 14 | /Source:\\SCCM.lab.net\Clienthealth$\client 15 | /MP:SCCM.LAB.NET 16 | 17 | 18 | 25 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/Copy-MCMContentFromDPtoDPGroup.ps1: -------------------------------------------------------------------------------- 1 | $SiteCode = "LAB" 2 | $ProviderMachineName = "CMPrimary.contoso.com" # SMS Provider machine name 3 | $DistributionPointGroupName = 'Data Center DPs' 4 | $SourceDPname = 'SourceDP.contoso.com' 5 | $TargetDPname = 'NewDP.contoso.com' 6 | 7 | 8 | # Import the ConfigurationManager.psd1 module 9 | if ($null -eq (Get-Module ConfigurationManager)) { Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" } 10 | 11 | # Connect to the site's drive if it is not already present 12 | if ($null -eq (Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue)) { New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName } 13 | 14 | # Set the current location to be the site code. 15 | Push-Location "$($SiteCode):\" 16 | 17 | 18 | $DeploymentPackages = Get-CMDeploymentPackage -DistributionPointName $SourceDPname 19 | #$DeploymentPackages | Select ObjectTypeID, PackageID, Name | Sort-Object ObjectTypeID, PackageID, Name 20 | #$DeploymentPackages.Count 21 | 22 | $DeploymentPackagesTarget = Get-CMDeploymentPackage -DistributionPointName $TargetDPname 23 | #$DeploymentPackagesTarget | Select ObjectTypeID, PackageID, Name | Sort-Object ObjectTypeID, PackageID, Name 24 | #$DeploymentPackagesTarget.Count 25 | 26 | $MissingPackages = $DeploymentPackages | Where-Object { $_.PackageID -notin $DeploymentPackagesTarget.PackageID } 27 | $MissingPackages | Select-Object ObjectTypeID, PackageID, Name | Sort-Object ObjectTypeID, PackageID, Name 28 | $MissingPackages.Count 29 | #$MissingPackages = $MissingPackages | Where { $_.PackageID -eq 'FC2001B2' } | Select * 30 | 31 | ForEach ($DeploymentPackage in $MissingPackages) { 32 | $CMContentDistributionParams = $null 33 | Switch ($DeploymentPackage.ObjectTypeID) { 34 | 2 { $CMContentDistributionParams = @{PackageID = $($DeploymentPackage.PackageID)} } 35 | 14 { $CMContentDistributionParams = @{OperatingSystemInstallerId = $($DeploymentPackage.PackageID)} } 36 | 18 { $CMContentDistributionParams = @{OperatingSystemImageId = $($DeploymentPackage.PackageID)} } 37 | 19 { $CMContentDistributionParams = @{BootImageId = $($DeploymentPackage.PackageID)} } 38 | 23 { $CMContentDistributionParams = @{DriverPackageID = $($DeploymentPackage.PackageID)} } 39 | 24 { $CMContentDistributionParams = @{DeploymentPackageID = $($DeploymentPackage.PackageID)} } 40 | 31 { $CMContentDistributionParams = @{ApplicationName = $($DeploymentPackage.Name)} } 41 | } 42 | If ($null -ne $CMContentDistributionParams) { 43 | Write-Output "Adding PackageID [$($DeploymentPackage.PackageID)] to Distribution Point Group [$DistributionPointGroupName]" 44 | Start-CMContentDistribution -DistributionPointGroupName $DistributionPointGroupName @CMContentDistributionParams 45 | } 46 | } 47 | 48 | Pop-Location -------------------------------------------------------------------------------- /ConfigMgr/Operations/Get-MCMDistributionPointDetails.ps1: -------------------------------------------------------------------------------- 1 | #.Synopsis 2 | # Get-MECMDistributionPointDetails.ps1 3 | # Get ConfigMgr Distribution Point role and drive detailed properties 4 | param ( 5 | [parameter(Mandatory=$true)][string]$SiteCode = 'LAB', 6 | [parameter()][string[]]$DistributionPoint 7 | ) 8 | 9 | 10 | Function Convert-CMScheduleToArray ($ScheduleString) { 11 | #$ScheduleString = '1523568894' 12 | #$ScheduleString = '' 13 | $CMSchedule = Convert-CMSchedule -ScheduleString $ScheduleString 14 | $Schedule = @("String=$ScheduleString") 15 | $Schedule += @("SmsProviderObjectPath=$($CMSchedule.SmsProviderObjectPath)") 16 | If($CMSchedule.SmsProviderObjectPath -eq 'SMS_ST_RecurInterval') { 17 | $Schedule += @("DayDuration=$($CMSchedule.DayDuration)") 18 | $Schedule += @("DaySpan=$($CMSchedule.DaySpan)") 19 | $Schedule += @("HourDuration=$($CMSchedule.HourDuration)") 20 | $Schedule += @("HourSpan=$($CMSchedule.HourSpan)") 21 | $Schedule += @("IsGMT=$($CMSchedule.IsGMT)") 22 | $Schedule += @("MinuteDuration=$($CMSchedule.MinuteDuration)") 23 | $Schedule += @("MinuteSpan=$($CMSchedule.MinuteSpan)") 24 | $Schedule += @("StartTime=$($CMSchedule.StartTime)") 25 | } ElseIf ($CMSchedule.SmsProviderObjectPath -eq 'SMS_ST_RecurWeekly') { 26 | $Schedule += @("Day=$($CMSchedule.Day)") 27 | $Schedule += @("DayDuration=$($CMSchedule.DayDuration)") 28 | $Schedule += @("ForNumberOfWeeks=$($CMSchedule.ForNumberOfWeeks)") 29 | $Schedule += @("HourDuration=$($CMSchedule.HourDuration)") 30 | $Schedule += @("IsGMT=$($CMSchedule.IsGMT)") 31 | $Schedule += @("MinuteDuration=$($CMSchedule.MinuteDuration)") 32 | $Schedule += @("StartTime=$($CMSchedule.StartTime)") 33 | } Else { 34 | } 35 | Return $Schedule 36 | } 37 | 38 | Push-Location -Path "$SiteCode`:" 39 | If ($DistributionPoint.count -eq 0) { 40 | $DistributionPoint = @((Get-CMDistributionPoint -SiteCode $SiteCode).NALPath.split('\')[2]) 41 | } 42 | 43 | $ProgressActivity = "ConfigMgr Distribution Point drive details: Processing server $Count of $($DistributionPoint.count)" 44 | Write-Progress -Activity $ProgressActivity -Status "$DPServer... getting DP object" 45 | 46 | $DPDriveInfo = Get-CMDistributionPointDriveInfo | Select NALPath, Drive, BytesTotal, BytesFree, ComputerName, GBTotal, GBFree, ConttentLibPriority, ObjectType, PercentFree, PkgSharePriority, Status, SiteCode; ForEach ($DP in $DPDriveInfo) { $DP.GBTotal = [math]::Round($DP.BytesTotal/1MB,1); $DP.GBFree = [math]::Round($DP.BytesFree/1MB,1); $DP.ComputerName = $DP.NALPath.split('\')[2];} 47 | 48 | $Count = 0 49 | #$DPsInfo += 50 | ForEach ($DPServer in $DistributionPoint) { 51 | $Count++ 52 | $ProgressActivity = "ConfigMgr Distribution Point details: Processing server $Count of $($DistributionPoint.count)" 53 | Write-Progress -Activity $ProgressActivity -Status "$DPServer... getting DP object" 54 | $DP = Get-CMDistributionPoint -SiteCode $SiteCode -SiteSystemServerName $DPServer 55 | $DPInfo = [ordered]@{ 56 | ComputerName = $DP.NALPath.split('\')[2] 57 | RoleCount = $DP.RoleCount 58 | RoleName = $DP.RoleName 59 | ServerState = $DP.ServerState 60 | ServiceWindows = $DP.ServiceWindows 61 | SiteSystemStatus = $DP.SiteSystemStatus 62 | #SSLstate = $DP.SslState 63 | Type = $DP.Type 64 | } 65 | ForEach ($Prop in $DP.EmbeddedProperties.Keys) { 66 | #"$($Prop) -> $($DPs.EmbeddedProperties["$Prop"])" 67 | $DPInfo.Add("$Prop",$DP.EmbeddedProperties["$Prop"].Value) 68 | } 69 | $DPInfo.ADSiteName = $DP.EmbeddedProperties['ADSiteName'].Value1 70 | $DPInfo.AvailableContentLibDrivesList = $DP.EmbeddedProperties['AvailableContentLibDrivesList'].Value1 71 | $DPInfo.AvailablePkgShareDrivesList = $DP.EmbeddedProperties['AvailablePkgShareDrivesList'].Value1 72 | $DPInfo.CertificateExpirationDate = $DP.EmbeddedProperties['CertificateExpirationDate'].Value #convert to date 73 | $DPInfo.DPMonSchedule = $DP.EmbeddedProperties['DPMonSchedule'].Value1 #may be more 74 | $DPInfo.IdentityGUID = $DP.EmbeddedProperties['IdentityGUID'].Value1 #may be more 75 | $DPInfo.IPSubnets = $DP.EmbeddedProperties['IPSubnets'].Value1 #may be more 76 | $DPInfo.LastIISConfigCheckTime = $DP.EmbeddedProperties['LastIISConfigCheckTime'].Value #convert to date 77 | $DPInfo.'Server Remote Name' = $DP.EmbeddedProperties['Server Remote Name'].Value1 78 | $DPInfo.'Site Info' = $DP.EmbeddedProperties['Site Info'].Value1 79 | $DPInfo.Version = $DP.EmbeddedProperties['Version'].Value1 80 | 81 | $DPInfo.DPMonSchedule = Convert-CMScheduleToArray -ScheduleString $DPInfo.DPMonSchedule 82 | $DPInfo.LastIISConfigCheckTime = Convert-CMScheduleToArray -ScheduleString $DPInfo.LastIISConfigCheckTime 83 | 84 | $DPInfo 85 | } 86 | Pop-Location 87 | 88 | #$DPsInfo 89 | $DPDriveInfo #| Select ComputerName, Drive, GBTotal, GBFree 90 | Write-Progress -Activity $ProgressActivity -Status "Done"; Start-Sleep -Seconds 1 91 | Write-Progress -Activity $ProgressActivity -Status "Done" -Completed -------------------------------------------------------------------------------- /ConfigMgr/Operations/Remove-MCMDistributionPointContent.ps1: -------------------------------------------------------------------------------- 1 |  2 | function Remove-SCCMDPContent 3 | { 4 | <# 5 | .Synopsis 6 | Function to Remove Packages from the DP 7 | .DESCRIPTION 8 | THis Function will connect to the SCCM Server SMS namespace and then remove the Package IDs 9 | passed to the Function from the specified DP name. 10 | .EXAMPLE 11 | PS> Remove-SCCMDPContent -PackageID DEX123AB,DEX145CD -DPname DexDP -Computername DexSCCMServer 12 | 13 | This will remove the Packages with Package IDs [ DEX123AB,DEX145CD] from the Distribution Point "DexDP". 14 | .INPUTS 15 | System.String[] 16 | .OUTPUTS 17 | System.Management.Automation.PSCustomObject 18 | .NOTES 19 | Author - DexterPOSH (Deepak Singh Dhami) 20 | 21 | #> 22 | 23 | [CmdletBinding()] 24 | [OutputType([PSObject])] 25 | Param 26 | ( 27 | # Specify the Package IDs which need to be removed from the DP 28 | [Parameter(Mandatory, 29 | ValueFromPipelineByPropertyName, 30 | Position=0)] 31 | [string[]]$PackageID, 32 | 33 | # Pass the DP name where cleanup is to be done 34 | [Parameter(Mandatory=$true)] 35 | [String]$DPName, 36 | 37 | #Supply the SCCM Site Server hosting SMS Namespace Provider 38 | [Parameter()] 39 | [Alias("SCCMServer")] 40 | [String]$ComputerName 41 | ) 42 | 43 | Begin 44 | { 45 | Write-Verbose -Message "[BEGIN]" 46 | try 47 | { 48 | 49 | $sccmProvider = Get-WmiObject -query "select * from SMS_ProviderLocation where ProviderForLocalSite = true" -Namespace "root\sms" -computername $ComputerName -errorAction Stop 50 | # Split up the namespace path 51 | $Splits = $sccmProvider.NamespacePath -split "\\", 4 52 | Write-Verbose "Provider is located on $($sccmProvider.Machine) in namespace $($splits[3])" 53 | 54 | # Create a new hash to be passed on later 55 | $hash= @{"ComputerName"=$ComputerName;"NameSpace"=$Splits[3];"Class"="SMS_DistributionPoint";"ErrorAction"="Stop"} 56 | 57 | #add the filter to get the packages there in the DP only 58 | $hash.Add("Filter","ServerNALPath LIKE '%$DPname%'") 59 | 60 | 61 | } 62 | catch 63 | { 64 | Write-Warning "Something went wrong while getting the SMS ProviderLocation" 65 | throw $_.Exception 66 | } 67 | } 68 | Process 69 | { 70 | 71 | 72 | Write-Verbose -Message "[PROCESS] Working to remove packages from DP --> $DPName " 73 | 74 | #get all the packages in the Distribution Point 75 | $PackagesINDP = Get-WmiObject @hash 76 | 77 | #Filter the packages based on the PackageID 78 | $RemovePackages = $PackagesINDP | where {$PackageID -contains $_.packageid } 79 | 80 | 81 | $Removepackages | ForEach-Object -Process { 82 | try 83 | { 84 | Remove-WmiObject -InputObject $_ -ErrorAction Stop -ErrorVariable WMIRemoveError 85 | Write-Verbose -Message "Removed $($_.PackageID) from $DPname" 86 | [pscustomobject]@{"DP"=$DPname;"PackageId"=$($_.PackageID);"Action"="Removed"} 87 | 88 | } 89 | catch 90 | { 91 | Write-Warning "[PROCESS] Something went wrong while removing the Package from $DPname" 92 | throw $_.exception 93 | } 94 | }#End Foreach-Object 95 | 96 | }#End Process 97 | End 98 | { 99 | Write-Verbose "[END] Ending the Function" 100 | } 101 | } -------------------------------------------------------------------------------- /ConfigMgr/Operations/Set-MCMDistributionPoint_DistributeOnDemand.ps1: -------------------------------------------------------------------------------- 1 | #.Synopsis 2 | # Set-MECMDistributionPoint_DistributeOnDemand.ps1 3 | # Enable/Disable ConfigMgr Distribution Point role DistributeOnDemand feature 4 | #.LINK 5 | # SCCM Check "Enable for on-demand distribution" In "Distribution Point Properties" DistributeOnDemand https://franckrichard.blogspot.com/2018/05/sccm-check-enable-for-on-demand.html 6 | [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact="Low")] 7 | param ( 8 | [parameter(Mandatory=$true)][string]$SiteCode = 'LAB', 9 | [parameter()][string[]]$DistributionPoint, 10 | [parameter(Mandatory=$true)][ValidateSet('Enable','Disable')][string]$Option 11 | ) 12 | 13 | If ($Option -eq 'Enable') { $DistributeOnDemand = 1 } 14 | If ($Option -eq 'Disable') { $DistributeOnDemand = 0 } 15 | 16 | Push-Location -Path "$SiteCode`:" 17 | If ($DistributionPoint.count -eq 0) { 18 | $DistributionPoint = @((Get-CMDistributionPoint -SiteCode $SiteCode).NALPath.split('\')[2]) 19 | } 20 | $Count = 0 21 | ForEach ($DPServer in $DistributionPoint) { 22 | $Count++ 23 | $ProgressActivity = "ConfigMgr Distribution Point Distribute On Demand feature: Processing server $Count of $($DistributionPoint.count)" 24 | Write-Progress -Activity $ProgressActivity -Status "$DPServer... getting DP object" 25 | $DP = Get-CMDistributionPoint -SiteCode $SiteCode -SiteSystemServerName $DPServer 26 | $props = $DP.EmbeddedProperties 27 | if ($DP.EmbeddedProperties.ContainsKey('DistributeOnDemand') ) { 28 | $props['DistributeOnDemand'].Value = $DistributeOnDemand 29 | } else { 30 | $props['DistributeOnDemand'] = New-CMEmbeddedProperty -PropertyName 'DistributeOnDemand' -Value $DistributeOnDemand 31 | } 32 | $DP.EmbeddedProperties = $props 33 | If ($WhatIfPreference -eq $false) { 34 | Write-Progress -Activity $ProgressActivity -Status "$DPServer... setting DP object" 35 | try { 36 | $DP.put() 37 | Write-Output "Set DP $DPServer DistributeOnDemand to $Option" 38 | } catch { 39 | Write-Error "Failed setting DP $DPServer DistributeOnDemand to $($DistributeOnDemand)" 40 | } 41 | } Else { 42 | Write-Output "Would have set DP $DPServer DistributeOnDemand to $Option" 43 | } 44 | } 45 | Pop-Location 46 | Write-Progress -Activity $ProgressActivity -Status "Done"; Start-Sleep -Seconds 1 47 | Write-Progress -Activity $ProgressActivity -Status "Done" -Completed 48 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/Status Message Filer Rule Scripts/Command-Line Parameters for Status Filter Rules.txt: -------------------------------------------------------------------------------- 1 | ConfigMgr: Command-Line Parameters for Status Filter Rules 2 | https://technet.microsoft.com/en-us/library/bb693758.aspx 3 | 4 | %msgsys Name of the computer that reported the message 5 | %msgdesc Complete message description text 6 | %msgis01 First "insertion string" 7 | ... 8 | %msgis10 Tenth "insertion string" 9 | %msgltm Time the message was reported, converted to local time: Month as decimal number (01 – 12) 10 | %msgltd Time the message was reported, converted to local time: Day of month as decimal number (01 – 31) 11 | %msgltY Time the message was reported, converted to local time: Year with century, as decimal number 12 | %msgltH Time the message was reported, converted to local time: Hour in 24-hour format (00 – 23) 13 | %msgltM Time the message was reported, converted to local time: Minute as decimal number (00 – 59) 14 | %msgltS Time the message was reported, converted to local time: Second as decimal number (00 – 59) 15 | 16 | %msgid Message ID of the message 17 | 18 | %msgltm/%msgltd/%msgltY %msgltH:%msgltM:%msgltS,%msgid,%msgsys,%msgdesc,%msgis01 19 | 20 | 21 | cmd.exe /c echo %msgltm/%msgltd/%msgltY %msgltH:%msgltM:%msgltS,%msgid,%msgsys,%msgdesc,%msgis01 >> E:\Logs\Custom\ConfigMgr_StatusMessages.csv 22 | cmd.exe /c echo %msgltm %msgltd %msgltY %msgltH %msgltM %msgltS,%msgid,%msgsys >> E:\Logs\Custom\ConfigMgr_StatusMessages.csv -------------------------------------------------------------------------------- /ConfigMgr/Operations/Status Message Filer Rule Scripts/Write-StatusMessageLog.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | ::.Example 3 | :: "E:\Program Files\ConfigMgr Tools\Write-StatusMessageLog.cmd" %msgltm/%msgltd/%msgltY %msgltH:%msgltM:%msgltS %msgid "%msgsys" "%msgdesc" "%msgis01" "%msgis02" 4 | :: cmd.exe /c echo %msgltm/%msgltd/%msgltY %msgltH:%msgltM:%msgltS,%msgid,%msgsys,%msgdesc,%msgis01 >> E:\Logs\Custom\ConfigMgr_StatusMessages.csv 5 | :: cmd.exe /c echo %msgltm %msgltd %msgltY %msgltH %msgltM %msgltS,%msgid,%msgsys >> E:\Logs\Custom\ConfigMgr_StatusMessages.csv 6 | 7 | ::.Notes 8 | :: ConfigMgr: Command-Line Parameters for Status Filter Rules 9 | :: https://technet.microsoft.com/en-us/library/bb693758.aspx 10 | :: 11 | :: %msgsys Name of the computer that reported the message 12 | :: %msgdesc Complete message description text 13 | :: %msgis01 First "insertion string" 14 | :: ... 15 | :: %msgis10 Tenth "insertion string" 16 | :: %msgltm Time the message was reported, converted to local time: Month as decimal number (01 – 12) 17 | :: %msgltd Time the message was reported, converted to local time: Day of month as decimal number (01 – 31) 18 | :: %msgltY Time the message was reported, converted to local time: Year with century, as decimal number 19 | :: %msgltH Time the message was reported, converted to local time: Hour in 24-hour format (00 – 23) 20 | :: %msgltM Time the message was reported, converted to local time: Minute as decimal number (00 – 59) 21 | :: %msgltS Time the message was reported, converted to local time: Second as decimal number (00 – 59) 22 | :: %msgid Message ID of the message 23 | :: %msgltm/%msgltd/%msgltY %msgltH:%msgltM:%msgltS,%msgid,%msgsys,%msgdesc,%msgis01 24 | 25 | set filename="D:\Logs\Custom\ConfigMgr_StatusMessages.csv" 26 | 27 | If NOT EXIST %filename% echo ComputerName;Timestamp;MessageType;Status;MessageDetails1;MessageDetails2;MessageDetails3;MessageDetails4;MessageDetails5 > %filename% 28 | echo %1;%2;%3;%4;%5;%6;%7;%8;%9 >> %filename% 29 | -------------------------------------------------------------------------------- /ConfigMgr/Operations/Update-MCMObjectSecurityScopes.ps1: -------------------------------------------------------------------------------- 1 | Function Update-MECMObjectSecurityScopes { 2 | #.Synopsis 3 | # Add and Remove Security Scopes from an array of ConfigMgr objects 4 | #.Notes 5 | # === To Do / Proposed Changes === 6 | # - TODO: add error handling 7 | param ( 8 | [Parameter(Mandatory = $true)]$ObjectID, 9 | [Parameter(Mandatory = $true)][string]$ObjectType, 10 | [Parameter(Mandatory = $false)][string]$AddScopeName, 11 | [Parameter(Mandatory = $false)][string]$RemoveScopeName, 12 | [Parameter(Mandatory = $true)][string]$SiteCode 13 | ) 14 | Begin { 15 | Connect-ConfigMgr 16 | Push-Location "$SiteCode`:\" 17 | $AddScope = Get-CMSecurityScope -Name $AddScopeName 18 | $RemoveScope = Get-CMSecurityScope -Name $RemoveScopeName 19 | Pop-Location 20 | } 21 | Process { 22 | ForEach ($ObjectIDInstance in $ObjectID) { 23 | Switch ($ObjectType) { 24 | 'Application' { 25 | Push-Location "$SiteCode`:\" 26 | $CMObject = Get-CMApplication -Id $ObjectIDInstance 27 | Pop-Location 28 | Write-LogMessage -Message "Verifying Application CI_ID [$($CMObject.CI_ID)] named [$($CMObject.LocalizedDisplayName)]" 29 | } 30 | 'Package' { 31 | Push-Location "$SiteCode`:\" 32 | $CMObject = Get-CMPackage -Id $ObjectIDInstance 33 | Pop-Location 34 | Write-LogMessage -Message "Verifying Package ID [$($CMObject.PackageID)] named [$($CMObject.Name)]" 35 | } 36 | 'TaskSequence' { 37 | Push-Location "$SiteCode`:\" 38 | $CMObject = Get-CMApplication -Id $ObjectIDInstance 39 | Pop-Location 40 | Write-LogMessage -Message "Verifying TaskSequence ID [$($CMObject.PackageID)] named [$($CMObject.Name)]" 41 | } 42 | } 43 | Push-Location "$SiteCode`:\" 44 | $CMObjectScopes = Get-CMObjectSecurityScope -InputObject $CMObject 45 | Pop-Location 46 | Write-LogMessage -Message "[$ObjectType] Object ID [$ObjectIDInstance] has [$($CMObjectScopes.Count)] scopes assigned" 47 | If ($CMObjectScopes.CategoryID -notcontains $AddScope.CategoryID) { 48 | #Add the production Security Scope if it isn't already added 49 | Write-LogMessage -Message "Adding scope [$AddScopeName] to [$ObjectType] Object ID [$ObjectIDInstance]" 50 | Push-Location "$SiteCode`:\" 51 | Add-CMObjectSecurityScope -InputObject $CMObject -Scope $AddScope -Confirm:$false -Force 52 | Pop-Location 53 | } 54 | If ($CMObjectScopes.CategoryID -contains $RemoveScope.CategoryID) { 55 | #Remove the lab Security Scope if it is added 56 | Write-LogMessage -Message "Removing scope [$RemoveScopeName] from [$ObjectType] Object ID [$ObjectIDInstance]" 57 | Push-Location "$SiteCode`:\" 58 | Remove-CMObjectSecurityScope -InputObject $CMObject -Scope $RemoveScope -Confirm:$false -Force 59 | Pop-Location 60 | } 61 | #Set-CMObjectSecurityScope -InputObject $CMPackage -Action AddMembership -Name 'Stores-Production' 62 | #Set-CMObjectSecurityScope -InputObject $CMPackage -Action RemoveMembership -Name 'Stores-TCoE Lab' 63 | #Add-CMObjectSecurityScope -InputObject $CMPackage -Name 'Stores-Production' 64 | #Remove-CMObjectSecurityScope -InputObject $CMPackage -Name 'Stores-TCoE Lab' 65 | } 66 | } 67 | End { 68 | } 69 | } -------------------------------------------------------------------------------- /ConfigMgr/Scheduled Scripts/Export-MCMCollectionMemberInfo.ps1: -------------------------------------------------------------------------------- 1 | #.Synopsis 2 | # Export-MCMCollectionMemberInfo.ps1 3 | #.Notes 4 | # 2023/08/21 by Chad.Simmons 5 | 6 | $SiteCode = 'LAB' 7 | $SiteServer = 'ConfigMgrPri.contoso.com' 8 | $ExportPath = "\\$SiteServer\Logs\Collection Info" 9 | 10 | 11 | #======================================================================================================================================= 12 | Function Write-LogMessage { 13 | #.Synopsis Write a log entry in CMTrace format with almost as little code as possible (i.e. Simplified Edition) 14 | param ($Message, [ValidateSet('Error', 'Warn', 'Warning', 'Info', 'Information', '1', '2', '3')]$Type = '1', $LogFile = $script:LogFile, [switch]$Console) 15 | If ([string]::IsNullOrEmpty($LogFile)) { $LogFile = "$env:SystemRoot\Logs\ScriptCMTrace.log" } 16 | If (-not(Test-Path 'variable:script:LogFile')) { $script:LogFile = $LogFile } 17 | Switch ($Type) { { @('2', 'Warn', 'Warning') -contains $_ } { $Type = 2 }; { @('3', 'Error') -contains $_ } { $Type = 3 }; Default { $Type = 1 } } 18 | If ($Console) { Write-Output "$(Get-Date -F 'yyyy/MM/dd HH:mm:ss.fff')`t$(Switch ($Type) { 2 { 'WARNING: '}; 3 { 'ERROR: '}})$Message" } 19 | try { 20 | Add-Content -Path "filesystem::$LogFile" -Encoding UTF8 -WhatIf:$false -Confirm:$false -Value "" -ErrorAction Stop 21 | } catch { Write-Warning -Message "Failed writing to log [$LogFile] with message [$Message]" } 22 | } 23 | 24 | Function Export-MCMCollectionMemberCounts ($NameFilter, $ExportFile) { 25 | Write-LogMessage -Message "Exporting membership counts for collections [$NameFilter]" 26 | Set-Location "$SiteCode`:" 27 | $Colls = Get-CMDeviceCollection -Name "$NameFilter" 28 | Set-Location -Path 'C:' 29 | $Coll = $Colls | Select-Object -First 1 30 | Write-LogMessage -Message "$($Coll.MemberCount) members exist in collection [$($Coll.Name)]" 31 | $Colls | Select-Object @{N='ReportTime'; E={$(Get-Date -Format $DateFormat -Date $script:dtNow)}}, MemberCount, @{N='LastRefreshTime'; E={$(Get-Date -Format $DateFormat -Date $_.LastRefreshTime)}}, @{N='LastMemberChangeTime'; E={$(Get-Date -Format $DateFormat -Date $_.LastMemberChangeTime)}}, Name | Export-Csv -Path "$ExportFile" -Append -NoTypeInformation 32 | } 33 | 34 | Function Export-MCMCollectionMembers ($NameFilter, $ExportFile) { 35 | Write-LogMessage -Message "Exporting membership for collections [$NameFilter]" 36 | Set-Location "$SiteCode`:" 37 | $Colls = Get-CMDeviceCollection -Name "$NameFilter" 38 | ForEach ($Coll in $Colls) { 39 | Write-LogMessage -Message "$($Coll.MemberCount) members exist in collection [$($Coll.Name)]" 40 | Get-CMCollectionMember -CollectionName $Coll.Name | Select-Object @{N='ReportTime'; E={$(Get-Date -Format $DateFormat -Date $script:dtNow)}},@{N='CollectionName'; E={$CollectionName}}, Name, ResourceId, SMSID, SiteCode, ADSiteName, BoundaryGroups, ClientVerion, CNAccessMP, CNIsOnInternet, CNLastOnlineTime, CNLastOfflineTime, DeviceOS, DeviceOSBuild, Domain, IsClient, IsActive, LastMPServerName, MACAddress, LastActiveTime, LastLogonUser, CurrentLogonUser, PrimaryUser, UserName | Export-CSV -Path "filesystem::$ExportFile" -NoTypeInformation -Append 41 | } 42 | } 43 | $LogPath = $ExportPath 44 | $script:Logfile = $(Join-Path -Path $LogPath -ChildPath 'Export-MCMCollectionMemberInfo.log') 45 | $script:dtNow = Get-Date 46 | $script:DateFormat = 'yyyy/MM/dd HH:mm:ss' 47 | 48 | Write-LogMessage -Message '========================= Initializing =========================' 49 | If (-not(Test-Path -Path $ExportPath -PathType Container)) { New-Item -ItemType Directory -Path $ExportPath -Force -ErrorAction Stop } 50 | Write-LogMessage -Message "ExportPath is [$ExportPath]" 51 | 52 | Write-LogMessage -Message 'Importing ConfigMgr PowerShell module' 53 | Import-Module ($Env:SMS_ADMIN_UI_PATH.Substring(0, $Env:SMS_ADMIN_UI_PATH.Length - 5) + '\ConfigurationManager.psd1') 54 | New-PSDrive -Name $SiteCode -PSProvider cmsite -Root $SiteServer -ErrorAction SilentlyContinue 55 | #======================================================================================================================================= 56 | 57 | 58 | $CollectionName = 'Windows 10 Professional' 59 | Export-MCMCollectionMemberCounts -NameFilter $CollectionName -ExportFile "$ExportPath\ConfigMgr Collection Count History - $CollectionName.csv" 60 | Export-MCMCollectionMembers -NameFilter $CollectionName -ExportFile "$ExportPath\ConfigMgr Collection Member History - $CollectionName.csv" 61 | 62 | Write-LogMessage -Message '========================= Complete =========================' 63 | -------------------------------------------------------------------------------- /ConfigMgr/Software Updates/Invoke-DGASoftwareUpdateMaintenance/config.ini: -------------------------------------------------------------------------------- 1 | ;Example configuration file 2 | ;Note-You will need to remove the WhatIfPreference configuration before changes to your environment will be made. 3 | WhatIfPreference 4 | ;LogFile=E:\Scripts\Scheduled\Invoke-DGASoftwareUpdateMaintenance.log 5 | Force 6 | DeclineByPlugins 7 | DeleteDeclined 8 | DeclineByTitle=@('*Security Only*','*Preview of*','(Preview)*','*Beta*','*Version Next*','*ARM64*','*en-gb*') 9 | MaxUpdateRuntime=@{'*Cumulative Update for Windows 10*'=90;'*Security Monthly Quality Rollup For Windows*'=90;'*Security and Quality Rollup for .NET*'=90} 10 | UpdateListOutputFile 11 | DeclineSuperseded 12 | DeclineLastLevelOnly 13 | ;ReSyncUpdates 14 | ;CleanSources 15 | ;CleanSUGs 16 | ;CombineSUGs=3 17 | ;RemoveEmptySUGs 18 | ;IncludeByProduct=@('*name*','*name*') 19 | ;ExcludeByProduct=@('*name*','*name*') 20 | ;ExcludeByTitle=@('*name*','*name*') 21 | ;ExclusionPeriod=3 22 | ;FirstRun 23 | ;MaxLogSize=2621440 24 | ;RunCleanUpWizard 25 | ;SiteCode=XYZ 26 | ;SyncLeadTime=5 27 | ;UpdateADRDeploymentPackages=Yearly 28 | ;UseCustomIndexes 29 | ;StandAloneWSUS=MyWSUSserver.contoso.com 30 | ;StandAloneWSUSPort=8530 31 | ;StandAloneWSUSSSL=$False -------------------------------------------------------------------------------- /ConfigMgr/Software Updates/Rename-MCMSoftwareUpdateGroupDeployments.ps1: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | #.SYNOPSIS 3 | # Rename-MECMSoftwareUpdateGroupDeployments.ps1 4 | # Rename ConfigMgr Software Update Group and its Deployments created by an ADR to YYYY-MM - 5 | #.PARAMETER SiteCode 6 | # Specifies 3 character ConfigMgr Site Code 7 | #.PARAMETER SiteServer 8 | # Specifies NetBIOS or FQDN of ConfigMgr Site Server (SMS Provider / Primary Site Server) 9 | #.PARAMETER YYYYMM 10 | # Specifies Year and Month in YYYY-MM format such as '2021-09'. Defaults to the current year and month 11 | #.PARAMETER ADRName 12 | # Specifies Automatic Deployment Rule Name 13 | #.EXAMPLE 14 | # Rename-MECMSoftwareUpdateGroupDeployments.ps1 -SiteCode LAB -SiteServer ConfigMgrPrimary.contoso.com -YYYYMM '2020-11' -ADRName 'Microsoft Monthly Updates' 15 | #.EXAMPLE 16 | # Rename-MECMSoftwareUpdateGroupDeployments.ps1 -SiteCode LAB -SiteServer ConfigMgrPrimary.contoso.com -ADRName 'Microsoft Monthly Updates' 17 | #.NOTES 18 | # Additional information about the function or script. 19 | # ========== Keywords ========== 20 | # Keywords: ConfigMgr SCCM MECM MEMCM Patch 21 | # ========== Change Log History ========== 22 | # - 2020/11/12 by Chad.Simmons@CatapultSystems.com - Created 23 | # - 2020/11/12 by Chad@ChadsTech.net - Created 24 | # === To Do / Proposed Changes === 25 | # #TODO: support WhatIf 26 | # #TODO: add logging 27 | # #TODO: add error handling 28 | ################################################################################ 29 | [cmdletbinding()] 30 | param ( 31 | [Parameter(Mandatory = $true, HelpMessage = 'ConfigMgr Site Code')][ValidateLength(3, 3)][string]$SiteCode, 32 | [Parameter(Mandatory = $true, HelpMessage = 'ConfigMgr Site Server (SMS Provider / Primary Site Server)')][ValidateLength(3, 255)][string]$SiteServer, 33 | [Parameter(Mandatory = $false, HelpMessage = 'Year and Month in YYYY-MM format')][string]$YYYYMM = $(Get-Date -Format 'yyyy-MM'), 34 | [Parameter(Mandatory = $true, HelpMessage = 'Automatic Deployment Rule Name')][string]$ADRName 35 | ) 36 | <# 37 | $SiteCode = 'LAB' 38 | $SiteServer = 'ConfigMgrPrimary.contoso.com' 39 | $YYYYMM = '2020-11' 40 | $ADRName = 'Microsoft Monthly Updates' 41 | #> 42 | 43 | $ADRDeploymentNames = "$ADRName_%_$YYYYMM-%" #template name 44 | $SUGName = "$ADRName $YYYYMM" 45 | 46 | Write-Host "Getting Software Update Group..." 47 | $SUGID = (Get-WmiObject -Computer $SiteServer -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_AuthorizationList -Filter "LocalizedDisplayName ='$SUGName'").CI_ID 48 | #$SUG = Get-CMSoftwareUpdateGroup -Name "$ADRName $(Get-Date -Date $YYYYMM -format 'yyyy-MM')-%" 49 | 50 | Write-Host "Renaming Software Update Group" 51 | If ($SUG) { Set-CMSoftwareUpdateGroup -InputObject $SUG -NewName "$SUGName" -Description "$ADRName $(Get-Date -Date $YYYYMM -Format 'MMMM yyyy')" } 52 | 53 | Write-Host "Getting Software Update Deployments" 54 | #$SUGdeployments = @(Get-WmiObject -Computer $SiteServer -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_UpdateGroupAssignment -Filter "AssignmentType=5 and AssignmentName like '$ADRDeploymentNames'") 55 | $SUGdeployments = @(Get-WmiObject -Computer $SiteServer -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_UpdateGroupAssignment -Filter "AssignmentType=5 and AssignedUpdateGroup = $SUGID") 56 | $SUGdeployments | Select-Object AssignmentUniqueID, TargetCollectionID, AssignedUpdateGroup, AssignmentName | Format-Table -AutoSize 57 | $SUGdeployments.Count 58 | 59 | Write-Host "Rename Software Update Group Deployments" 60 | #$SUGdeployment = $SUGdeployments | Select -First 1 61 | ForEach ($SUGdeployment in $SUGdeployments) { 62 | $CollectionName = (Get-WmiObject -Computer $SiteServer -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_Collection -Filter "CollectionID = '$($SUGDeployment.TargetCollectionID)'").Name 63 | $NewAssignmentName = "$SUGName - $CollectionName" 64 | Write-Host "SUDeployment [$($SUGDeployment.AssignmentUniqueID)] `n old name [$($SUGDeployment.AssignmentName)] `n new name [$NewAssignmentName]" 65 | $SUGDeployment.AssignmentName = $NewAssignmentName 66 | [void]$($SUGDeployment.Put()) 67 | Remove-Variable CollectionName, NewAssignmentName | Out-Null 68 | } 69 | Write-Host "Validating Software Update Deployments" 70 | $SUGdeployments = @(Get-WmiObject -Computer $SiteServer -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_UpdateGroupAssignment -Filter "AssignmentType=5 and AssignedUpdateGroup = $SUGID") 71 | $SUGdeployments | Select-Object AssignmentUniqueID, TargetCollectionID, AssignedUpdateGroup, AssignmentName | Format-Table -AutoSize -------------------------------------------------------------------------------- /ConfigMgr/Task Sequences/Copy-LogsToArchive.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/ConfigMgr/Task Sequences/Copy-LogsToArchive.ps1 -------------------------------------------------------------------------------- /InstallTemplate-Batch-Simple.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | set AppTitle=My Application Mame 4 | set SetupFile=My Application EXE (or MSIEXEC.exe or WUSA.exe) 5 | set SetupOPT=/quiet /norestart /log "%WinDir%\Logs\%AppTitle%.log" 6 | REM #################################################################################################################### 7 | If /I "%1"=="/h" goto:about 8 | If /I "%1"=="/help" goto:about 9 | goto:main 10 | :about 11 | echo ################################################################################################################### 12 | echo .Synopsis 13 | echo ScriptFileName.cmd 14 | echo Install %AppTitle% 15 | echo .Description 16 | echo Install software, updates, and configurations 17 | echo .Parameters 18 | echo [/h] [/help] display this help information 19 | echo .Parameter 20 | echo The description of a parameter 21 | echo .Example 22 | echo ScriptFileName.cmd Parameter1 23 | echo A sample command that uses the function or script, optionally followed by sample output and a description 24 | echo .Link 25 | echo The name and/or URL of a related topic 26 | echo .NOTES 27 | echo This script is maintained at ?????????????????????????????????????????????????????????????????????????????????? 28 | echo Additional information about the function or script. 29 | echo ========== Keywords ========================= 30 | echo Keywords: ??? 31 | echo ========== Change Log History =============== 32 | echo - YYYY/MM/DD by name@contoso.com - ~updated description~ 33 | echo - YYYY/MM/DD by name@contoso.com - created 34 | echo ========== To Do / Proposed Changes ========= 35 | echo - #TODO: None 36 | echo ===== Additional References and Reading ===== 37 | echo - : https://domain.url 38 | echo ################################################################################################################### 39 | goto:eof 40 | :main 41 | set ScriptPath=%~dp0 42 | set ScriptPath=%ScriptPath:~,-1% 43 | SET SetupType=%SetupFile:~-4% 44 | 45 | If [%SetupType%]==[.exe] start /wait "Installing %AppTitle%..." "%ScriptPath%\%SetupEXE%" %SetupOPT% 46 | If [%SetupType%]==[.msi] start /wait "Installing %AppTitle%..." msiexec.exe /i "%ScriptPath%\%SetupFile%" %SetupOPT% 47 | If [%SetupType%]==[.msu] start /wait "Installing %AppTitle%..." wusa.exe "%ScriptPath%\%SetupFile%" %SetupOPT% 48 | If [%SetupType%]==[.vbs] start /wait "Installing %AppTitle%..." cscript.exe "%ScriptPath%\%SetupFile%" %SetupOPT% 49 | If [%SetupType%]==[.ps1] start /wait "Installing %AppTitle%..." PowerShell.exe -ExecutionPolicy Bypass -file "%ScriptPath%\%SetupFile%" %SetupOPT% 50 | 51 | exit /b %errorlevel% 52 | :eof -------------------------------------------------------------------------------- /Intune/Export-M365Configurations.ps1: -------------------------------------------------------------------------------- 1 | #Export-M365Configurations.ps1 2 | $StartTime = Get-Date 3 | $StartTimeFormatted = $StartTime.ToString('yyyyMMddHHmm') 4 | 5 | 6 | 7 | #CECO Environmental 8 | $ClientID = '11111111-2222-3333-4444-555555555555' 9 | $TenantID = '11111111-2222-3333-4444-555555555555' 10 | $SecretID = '11111111-2222-3333-4444-555555555555' 11 | $SecretKey = 'uQT8Q~dRCoTA949UMcWA-U9UdRCoTAlG84d4V7ZfN-9d4F_bxX' 12 | 13 | 14 | $BasePath = $(Join-Path -Path $([System.Environment]::GetFolderPath('Personal')) -ChildPath 'Scripted Documentation') 15 | If (-not(Test-Path -Path $BasePath -PathType Container -ErrorAction SilentlyContinue)) { 16 | New-Item -ItemType Directory -Path $BasePath -ErrorAction SilentlyContinue 17 | } 18 | 19 | #region ===== Automated Microsoft 365 Documentation by Thomas Kurth ==================================================== 20 | #https://github.com/ThomasKur/M365Documentation 21 | Install-Module MSAL.PS 22 | Install-Module PSWriteWord 23 | Install-Module M365Documentation 24 | #Import-Module M365Documentation 25 | 26 | 27 | Function Write-M365DocumentationEx ($doc, $FullDocumentationPath) { 28 | # Output the documentation 29 | $doc | Write-M365DocJson -FullDocumentationPath "$FullDocumentationPath.json" -Verbose 30 | $doc | Write-M365DocWord -FullDocumentationPath "$FullDocumentationPath.docx" -Verbose 31 | 32 | $CSVPath = $(Join-Path -Path $env:SystemDrive -ChildPath $([System.IO.Path]::GetRandomFileName())) 33 | If (-not(Test-Path -Path $CSVPath -PathType Container -ErrorAction SilentlyContinue)) { 34 | [void](New-Item -ItemType Directory -Path $CSVPath -ErrorAction SilentlyContinue) 35 | } 36 | $doc | Write-M365DocCsv -ExportFolder $CSVPath -Verbose 37 | Compress-Archive -Path "$CSVPath\*.*" -DestinationPath "$FullDocumentationPath - CSV.zip" 38 | Remove-Item -Path $CSVPath -Recurse -Force 39 | } 40 | 41 | # Connect to your tenant 42 | #Connect-M365Doc 43 | Connect-M365Doc -ClientID $ClientID -TenantId $TenantID 44 | 45 | # Collect information for component Intune 46 | $doc = Get-M365Doc -Components Intune -ExcludeSections 'MobileAppDetailed' 47 | #$StartTimeFormatted = $doc.CreationDate.ToString('yyyyMMddHHmm') 48 | 49 | $OrgPath = Join-Path -Path $BasePath -ChildPath $($doc.Organization) 50 | If (-not(Test-Path -Path $OrgPath -PathType Container -ErrorAction SilentlyContinue)) { 51 | New-Item -ItemType Directory -Path $OrgPath -ErrorAction SilentlyContinue 52 | } 53 | 54 | Write-M365DocumentationEx -Doc $doc -FullDocumentationPath "$OrgPath\M365 Automated Documentation - $($doc.Organization) - $($doc.Components) - $StartTimeFormatted" 55 | Remove-Variable -Name doc 56 | 57 | # Collect information for component AzureAD 58 | $doc = Get-M365Doc -Components AzureAD -IncludeSections AADConditionalAccess, AADBranding, AADOrganization, AADPolicy, AADSubscription, AADDirectoryRole, AADDomain 59 | Write-M365DocumentationEx -Doc $doc -FullDocumentationPath "$OrgPath\M365 Automated Documentation - $($doc.Organization) - $($doc.Components) - $StartTimeFormatted" 60 | Remove-Variable -Name doc, BasePath, OrgPath 61 | 62 | #endregion ===== Automated Microsoft 365 Documentation by Thomas Kurth ================================================> -------------------------------------------------------------------------------- /Intune/Test-PowerShell_via_Intune.ps1: -------------------------------------------------------------------------------- 1 | $OutputFile = "$env:ProgramData\Microsoft\Intune Management Extension\Logs\Intune PowerShell script test.log" 2 | Add-Content -Path $OutputFile -Value "Intune invoked a PowerShell script at $(Get-Date)" 3 | If (Test-Path -Path $OutputFile -PathType Leaf) { 4 | exit 0 5 | } Else { 6 | Write-Error -Message 'File not found' 7 | Exit 2 8 | } -------------------------------------------------------------------------------- /Microsoft Updates/Install-MSUpdate.cmd: -------------------------------------------------------------------------------- 1 | @ECHO off 2 | SETLOCAL 3 | ::SetupTitle is the Name of the Microsoft Update. 4 | ::SetupFile is of the Microsoft Update. If not specified, the script with accept a file name form the command line. 5 | :: If neither specified or from command line, the most recently modified MSU file in the script directory will be used 6 | SET SetupTitle= 7 | SET SetupFile= 8 | SET SetupOPT=/quiet /norestart 9 | 10 | If /I [%1]==[/h] GOTO:Help 11 | If /I [%1]==[-h] GOTO:Help 12 | If /I [%1]==[/help] GOTO:Help 13 | If /I [%1]==[-help] GOTO:Help 14 | GOTO:Begin 15 | :Help 16 | ECHO =============================================================================== 17 | ECHO .Synopsis 18 | ECHO Install Microsoft Update (MSU format) 19 | ECHO .Description 20 | ECHO Install update and process return code from WUSA.exe 21 | ECHO .Parameter 22 | ECHO [/h] [/help] display this help information 23 | ECHO .Parameter 24 | ECHO [file name.msu] Optional command line parameter of a MSU file in the same folder which should be installed 25 | ECHO .Notes 26 | ECHO === Change Log History === 27 | ECHO 2020/08/03 by Chad.Simmons@CatapultSystems.com - updated return code processing, added auto MSU detection and command line parameter for MSU 28 | ECHO 2017/05/15 by Chad.Simmons@CatapultSystems.com - Created 29 | ECHO ================================================================================ 30 | GOTO:EOF 31 | :Begin 32 | SET SourceDir=%~dp0 33 | SET SourceDir=%SourceDir:~,-1% 34 | 35 | ::If SetupFile is not specified set SetupFile to the most recently modified MSU file in the SourceDir 36 | IF NOT [%1]==[] SET SetupFile=%1 37 | IF [%SetupFile%]==[] FOR /f %%a IN ('dir /b /a-d /od *.msu') DO SET SetupFile=%%a 38 | IF [%SetupFile%]==[] EXIT /b 2 39 | IF ["%SetupTitle%"]==[""] SET SetupTitle=%SetupFile% 40 | ECHO "Installing [%SetupTitle%]. Running [%SetupFile%]" 41 | START /wait "Installing %SetupTitle%..." %WinDir%\System32\WUSA.exe "%SourceDir%\%SetupFile%" %SetupOPT% 42 | SET ReturnCode=%errorlevel% 43 | :: ===== Process Return Code ===== 44 | :: Decimal / Hex ERROR_NAME: Error description 45 | :: 0 / 0x0 ERROR_SUCCESS: Success, no reboot required 46 | :: 1618 / 0x652 ERROR_INSTALL_ALREADY_RUNNING: Another installation is already in progress. Complete that installation before proceeding with this install. (ConfigMgr: Fast Retry) 47 | :: 1641 / 0x669 ERROR_SUCCESS_REBOOT_INITIATED: The installer has initiated a restart. This message is indicative of a success. (ConfigMgr: Hard Reboot) 48 | :: The requested operation completed successfully. The system will be restarted so the changes can take effect. 49 | :: 1707 / 0x6ab Installation operation completed successfully 50 | :: 3010 / 0xbc2 ERROR_SUCCESS_REBOOT_REQUIRED: Success, soft reboot required 51 | :: 2359301 / 0x240005 WU_S_REBOOT_REQUIRED: The system must be restarted to complete installation of the update. 52 | :: 2359302 / 0x240006 WU_S_ALREADY_INSTALLED: The update to be installed is already installed on the system. 53 | :: 2359303 / 0x240007 WU_S_ALREADY_UNINSTALLED: The update to be removed is not installed on the system. 54 | ::-2145124343 / 0x80240009 WU_E_OPERATIONINPROGRESS: Another conflicting operation was in progress. Some operations such as installation cannot be performed twice simultaneously. 55 | ::-2145124330 / 0x80240016 WU_E_INSTALL_NOT_ALLOWED: Operation tried to install while another installation was in progress or the system was pending a mandatory restart. 56 | ::-2145124329 / 0x80240017 WU_E_NOT_APPLICABLE: Operation was not performed because there are no applicable updates. 57 | If %ReturnCode%==1707 SET ReturnCode=0 58 | If %ReturnCode%==2359301 SET ReturnCode=3010 59 | If %ReturnCode%==2359302 SET ReturnCode=0 60 | If %ReturnCode%==2359303 SET ReturnCode=0 61 | If %ReturnCode%==-2145124343 SET ReturnCode=1618 62 | If %ReturnCode%==-2145124330 SET ReturnCode=1618 63 | If %ReturnCode%==-2145124329 SET ReturnCode=0 64 | EXIT /b %ReturnCode% -------------------------------------------------------------------------------- /Microsoft Updates/Install-MSUpdates.cmd: -------------------------------------------------------------------------------- 1 | @ECHO off 2 | SETLOCAL 3 | SET SetupOPT=/quiet /norestart 4 | 5 | If /I [%1]==[/h] GOTO:Help 6 | If /I [%1]==[-h] GOTO:Help 7 | If /I [%1]==[/help] GOTO:Help 8 | If /I [%1]==[-help] GOTO:Help 9 | GOTO:Begin 10 | :Help 11 | ECHO =============================================================================== 12 | ECHO .Synopsis 13 | ECHO Install all Microsoft Updates (MSU format) in a folder 14 | ECHO .Description 15 | ECHO Install updates and process return code from WUSA.exe 16 | ECHO WARNING: Only the last update's return code is sent to the calling process 17 | ECHO .Parameter 18 | ECHO [/h] [/help] display this help information 19 | ECHO .Parameter 20 | ECHO [/ByName|/ByDate] install in order of name (ascending) or modified date (ascending) 21 | ECHO .Notes 22 | ECHO === Change Log History === 23 | ECHO 2022/11/02 by Chad.Simmons@CatapultSystems.com - fixed typo 24 | ECHO 2020/08/03 by Chad.Simmons@CatapultSystems.com - updated return code processing 25 | ECHO 2017/05/15 by Chad.Simmons@CatapultSystems.com - Created 26 | ECHO ================================================================================ 27 | GOTO:EOF 28 | :Begin 29 | SET SourceDir=%~dp0 30 | SET SourceDir=%SourceDir:~,-1% 31 | SET Continue=true 32 | SET PendingRestart=false 33 | 34 | If "%1"=="/ByName" GOTO:InstallByName 35 | If "%1"=="-ByName" GOTO:InstallByName 36 | GOTO:InstallByDate 37 | :InstallByName 38 | ::Find all MSU files and install in order of name 39 | FOR /f %%a IN ('dir /b /a-d /on *.msu') DO CALL:InstallMSU %%a 40 | GOTO:End 41 | :InstallByDate 42 | ::Find all MSU files and install in order of date modified 43 | FOR /f %%a IN ('dir /b /a-d /od *.msu') DO CALL:InstallMSU %%a 44 | GOTO:End 45 | 46 | :InstallMSU 47 | If %Continue%==true ( 48 | START /wait "Installing %1..." %WinDir%\System32\WUSA.exe "%SourceDir%\%1" %SetupOPT% 49 | SET ReturnCode=%ERRORLEVEL% 50 | :: ===== Process Return Code ===== 51 | :: Decimal / Hex ERROR_NAME: Error description 52 | :: 0 / 0x0 ERROR_SUCCESS: Success, no reboot required 53 | :: 1618 / 0x652 ERROR_INSTALL_ALREADY_RUNNING: Another installation is already in progress. Complete that installation before proceeding with this install. (ConfigMgr: Fast Retry) 54 | :: 1641 / 0x669 ERROR_SUCCESS_REBOOT_INITIATED: The installer has initiated a restart. This message is indicative of a success. (ConfigMgr: Hard Reboot) 55 | :: The requested operation completed successfully. The system will be restarted so the changes can take effect. 56 | :: 1707 / 0x6ab Installation operation completed successfully 57 | :: 3010 / 0xbc2 ERROR_SUCCESS_REBOOT_REQUIRED: Success, soft reboot required 58 | :: 2359301 / 0x240005 WU_S_REBOOT_REQUIRED: The system must be restarted to complete installation of the update. 59 | :: 2359302 / 0x240006 WU_S_ALREADY_INSTALLED: The update to be installed is already installed on the system. 60 | :: 2359303 / 0x240007 WU_S_ALREADY_UNINSTALLED: The update to be removed is not installed on the system. 61 | ::-2145124343 / 0x80240009 WU_E_OPERATIONINPROGRESS: Another conflicting operation was in progress. Some operations such as installation cannot be performed twice simultaneously. 62 | ::-2145124330 / 0x80240016 WU_E_INSTALL_NOT_ALLOWED: Operation tried to install while another installation was in progress or the system was pending a mandatory restart. 63 | ::-2145124329 / 0x80240017 WU_E_NOT_APPLICABLE: Operation was not performed because there are no applicable updates. 64 | If %ReturnCode%==-2145124343 SET Continue=false 65 | If %ReturnCode%==-2145124343 SET ReturnCode=1618 66 | If %ReturnCode%==-2145124330 SET Continue=false 67 | If %ReturnCode%==-2145124330 SET ReturnCode=1618 68 | If %ReturnCode%==-2145124329 SET ReturnCode=0 69 | If %ReturnCode%==2359301 SET ReturnCode=3010 70 | If %ReturnCode%==2359302 SET ReturnCode=0 71 | If %ReturnCode%==2359303 SET ReturnCode=0 72 | If %ReturnCode%==1707 SET ReturnCode=0 73 | If %ReturnCode%==3010 SET PendingRestart=true 74 | ) 75 | GOTO:EOF 76 | 77 | :END 78 | If %PendingRestart%==true EXIT /b 3010 79 | EXIT /b %ReturnCode% -------------------------------------------------------------------------------- /Microsoft Updates/Install-MicrosoftUpdatesPSADT/AppDeployToolkit.url: -------------------------------------------------------------------------------- 1 | [{000214A0-0000-0000-C000-000000000046}] 2 | Prop3=19,11 3 | [InternetShortcut] 4 | IDList= 5 | URL=https://github.com/PSAppDeployToolkit/PSAppDeployToolkit/releases 6 | -------------------------------------------------------------------------------- /Microsoft Updates/Install-MicrosoftUpdatesPSADT/readme.md: -------------------------------------------------------------------------------- 1 | download PSADT and add files here -------------------------------------------------------------------------------- /Microsoft Updates/README.md: -------------------------------------------------------------------------------- 1 | Scripts for installing and uninstalling Microsoft Updates and Windows Updates (MSU / EXE / CAB) -------------------------------------------------------------------------------- /Microsoft Updates/Remove-HotfixesInstalledInLast1Day.ps1: -------------------------------------------------------------------------------- 1 | #.Synopsis 2 | # Uninstall any Microsoft Hotfix / KB / Patch / Update installed in the last 1 day that is detectable by Get-Hotfix 3 | #.Note 4 | # https://rsr72.wordpress.com/2012/07/23/uninstall-microsoft-hotfixes-with-powershell/ 5 | # http://techibee.com/powershell/powershell-uninstall-windows-hotfixesupdates/1084 6 | 7 | $Hotfixes = Get-HotFix Select-Object CSName, HotFixID, Description, InstalledBy, InstalledOn, @{Name = 'InventoriedOn'; Expression = { $(Get-Date) } } 8 | $HotfixesInstalledRecently = @(Get-HotFix | Where-Object InstalledOn -GE (Get-Date).AddDays(-1)) 9 | $Hotfixes | Sort-Object InstalledOn | Out-GridView #Format-Table -AutoSize 10 | $Hotfixes | Sort-Object InstalledOn | Export-CSV -Path "$env:SystemRoot\Logs\Hotfixes Installed.csv" -Append -NoTypeInformation 11 | ForEach ($Hotfix in $HotfixesInstalledRecently) { 12 | $i += 1 13 | Write-Output "Uninstalling ($($Hotfix).HotFixID)" 14 | If ($i -ne $(($HotfixesInstalledRecently).Count)) { 15 | Start-Process -FilePath 'wusa.exe' -ArgumentList "/uninstall /kb:$(($hotfix).HotFixID -replace 'KB','') /quiet /norestart" 16 | While (@(Get-Process wusa -ErrorAction SilentlyContinue).Count -ne 0) { 17 | Start-Sleep 3 18 | Write-Host "Waiting for update removal to finish ..." 19 | } 20 | } else { 21 | Start-Process -FilePath 'wusa.exe' -ArgumentList "/uninstall /kb:$(($hotfix).HotFixID -replace 'KB','') /quiet /promptrestart" 22 | } 23 | } 24 | #Write-Output "Completed the uninstallation of $(($Hotfixes).Count) hotfixes" -------------------------------------------------------------------------------- /Microsoft Updates/Remove-MicrosoftUpdate.ps1: -------------------------------------------------------------------------------- 1 | [string]$KBid = '5020023' #November 8, 2022—KB5020023 (Monthly Rollup) https://support.microsoft.com/en-us/topic/november-8-2022-kb5020023-monthly-rollup-9ac62145-0c72-4faf-b5c9-e787f6b19b4d 2 | [string]$PackageNameFilter = 'Package_for_RollupFix*.2251.*' #$null 3 | 4 | ######################################################################################################################## 5 | #.SYNOPSIS 6 | # Remove-MicrosoftUpdate.ps1 7 | # Uninstall Microsoft Update / Patch / KB (solution Simple Edition) 8 | #.NOTES 9 | # Keywords: Uninstall, Remove; Microsoft Support; KB, Update, Patch, Hotfix 10 | # ========== Change Log History =============== 11 | # - 2022/12/01 by GitHub @ChadSimmons / Chad.Simmons@Quisitive.com - created 12 | 13 | [bool]$HotfixIsInstalled = $(($Hotfixes).HotFixID -contains $('KB' + $KBid)) 14 | $PackageName = (Get-WindowsPackage -Online | Where-Object { $_.PackageState -eq 'Installed' -and $_.PackageName -like $PackageNameFilter }).PackageName 15 | If ($null -eq $PackageName -and $HotfixIsInstalled -eq $false) { 16 | Write-Output $('KB' + $KBid + ' is not installed') 17 | Exit 0 18 | } Else { 19 | Write-Output $('Uninstalling KB' + $KBid) 20 | If ($null -ne $PackageName) { 21 | Remove-WindowsPackage -PackageName $PackageName -Online -NoRestart -LogPath $("$env:SystemRoot\Logs\KB" + $KBid + '.log') 22 | } 23 | If ($HotfixIsInstalled -eq $true) { 24 | Start-Process -FilePath "$env:SystemRoot\System32\wusa.exe" -ArgumentList "/uninstall /kb:$KBid /quiet /norestart /log:$("$env:SystemRoot\Logs\KB" + $KBid + '.log')" -Wait 25 | } 26 | 27 | #Check if the registry key RebootRequired is present. It is created when Windows Updates are applied and require a reboot to take place 28 | $PatchReboot = [bool](Get-ChildItem -Path REGISTRY::"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -ErrorAction SilentlyContinue) 29 | 30 | #Check if the RebootPending key is present. It is created when changes are made to the component store that require a reboot to take place 31 | $ComponentBasedReboot = [bool](Get-ChildItem -Path REGISTRY::"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -ErrorAction SilentlyContinue) 32 | 33 | #Check if File rename operations are taking place and require a reboot for the operation to take effect 34 | $PendingFileRename = [bool]((Get-ItemProperty -Path REGISTRY::"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager" -ErrorAction SilentlyContinue).PendingFileRenameOperations) 35 | 36 | #WMI query of the Microsoft Configuration Manager service to check if a reboot is pending 37 | $ConfigMgrReboot = Invoke-WmiMethod -Namespace 'ROOT\ccm\ClientSDK' -Class CCM_ClientUtilities -Name DetermineIfRebootPending | Select-Object -ExpandProperty 'RebootPending' 38 | 39 | #Update ConfigMgr inventory 40 | Invoke-WmiMethod -Namespace root\ccm -Class sms_client -Name TriggerSchedule -ArgumentList '{00000000-0000-0000-0000-000000000003}' -ErrorAction Stop # Discovery Data Collection Cycle 41 | Invoke-WmiMethod -Namespace root\ccm -Class sms_client -Name TriggerSchedule -ArgumentList '{00000000-0000-0000-0000-000000000001}' -ErrorAction Stop # Hardware Inventory Collection Cycle 42 | Invoke-WmiMethod -Namespace root\ccm -Class sms_client -Name TriggerSchedule -ArgumentList '{00000000-0000-0000-0000-000000000113}' -ErrorAction Stop # Software Update Scan Cycle 43 | 44 | #Test and return reboot pending status 45 | If ($PatchReboot -eq $true -or $ComponentBasedReboot -eq $true -or $PendingFileRename -eq $true -or $ConfigMgrReboot -eq $true) { 46 | Write-Output 'Reboot required' 47 | Exit 3010 48 | } Else { 49 | Write-Output 'reboot NOT required' 50 | Exit 0 51 | } 52 | } -------------------------------------------------------------------------------- /Microsoft Updates/Set-QualityCompatRegKey.ps1: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | #.SYNOPSIS 3 | # Set-QualityCompatReg.ps1 4 | # Create / Set the registry key to all Windows 7/2008 R2 and newer operating systems to continue receiving Microsoft 5 | # Updates (patches) after January 2018. This setting is related to the Meltdown and Spectre vulnerabilities. 6 | #.LINK 7 | # Important: Windows security updates released January-February, 2018, and antivirus software (KB4072699) 8 | # https://support.microsoft.com/en-us/help/4072699/january-3-2018-windows-security-updates-and-antivirus-software 9 | #.NOTES 10 | # This script is maintained at https: //github.com/ChadSimmons/Scripts 11 | # Additional information about the function or script. 12 | # ========== Change Log History ========== 13 | # - 2018/02/16 by Chad.Simmons@CatapultSystems.com - Created 14 | # - 2018/02/16 by Chad@ChadsTech.net - Created 15 | ################################################################################ 16 | 17 | #region ######################### Main Script ############################### 18 | $RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat' 19 | $RegName = 'cadca5fe-87d3-4b96-b7fb-a231484277cc' 20 | New-Item -Path "$RegPath" -ItemType 'Key' -ErrorAction SilentlyContinue 21 | New-ItemProperty -Path "$RegPath" -Name "$RegName" -Value 0 -PropertyType 'DWORD' -Force -ErrorAction SilentlyContinue 22 | If ($(Get-ItemProperty -Path "$RegPath" -Name $RegName).$RegName -ne 0) { Exit 2 } 23 | #endregion ######################### Main Script ############################### -------------------------------------------------------------------------------- /Misc/Click-ButtonContinuously.au3: -------------------------------------------------------------------------------- 1 | ;AutoItSetOption ("WinTitleMatchMode", 3) 2 | $DialogTitle = "Error Applying Attributes" 3 | $IdentifyingText = "Access is denied." 4 | While 1 ;run forever 5 | If WinWait($DialogTitle, $IdentifyingText, 5) <> 0 Then ;wait up to 30 seconds for the dialog box with the title and text to exist 6 | ControlClick($DialogTitle, $IdentifyingText, "[CLASS:Button; INSTANCE:1]") ;click the button to Ignore 7 | EndIf 8 | WEnd -------------------------------------------------------------------------------- /Misc/Move-FilesByNameDate.ps1: -------------------------------------------------------------------------------- 1 | #$VerbosePreferenceBAK = $VerbosePreference 2 | #$VerbosePreference = 'Continue' 3 | $Debug = $false #$true 4 | 5 | $PathRoot = 'D:\Pictures\Photo.Inbox\Import.20160000' #'F:\Pictures\Inbox\Move.now\PHOTO' 6 | $DestinationRoot = $PathRoot 7 | $i = 0 8 | $files = Get-ChildItem -Path $PathRoot -File 9 | 10 | #$file = $files | Where { $_.Name -like 'P*' } | Select -First 1 11 | #$file 12 | ForEach ($file in $files) { 13 | $i++; $isDay = $false 14 | Write-Progress -Activity 'Moving files based on name as date' -Status "File $i of $($files.Count)" 15 | 16 | #check for a file name like yyyyMMdd_*.* 17 | $Day = ($file.BaseName -split '_')[0] 18 | If ($isDay -eq $false -and $Day -gt 19000000 -and $Day -le (Get-Date -Format yyyyMMdd)) { 19 | $isDay = $true 20 | Write-Verbose "file $($file.Name) begins with what appears to be a date in the format of yyyyMMdd" 21 | } 22 | 23 | If ($isDay -eq $false) { 24 | #check for a file name like yyyyMMdd*.* 25 | If ([bool]$file.BaseName -as [double]) { #isNumeric $file.BaseName 26 | $Day = ($file.BaseName).substring(0,8) 27 | } 28 | If ($Day -gt 19000000 -and $Day -le (Get-Date -Format yyyyMMdd)) { 29 | $isDay = $true 30 | Write-Verbose "file $($file.Name) begins with what appears to be a date in the format of yyyyMMdd" 31 | } 32 | } 33 | <# 34 | If ($isDay -eq $false) { 35 | #check for a file name like PHOTO_yyyyMMdd_*.* 36 | 37 | ($file.BaseName -match '^PHOTO_[1-2][0|9]\d\d\d\d\d\d_*') 38 | 39 | $Day = ($file.BaseName -split '_')[1] 40 | If ($Day -gt 19000000 -and $Day -le (Get-Date -Format yyyyMMdd)) { 41 | $isDay = $true 42 | Write-Verbose "file $($file.Name) begins with what appears to be a date in the format of [text]_yyyyMMdd_" 43 | } 44 | } 45 | #> 46 | 47 | If ($Debug -ne $true) { 48 | If ($isDay -eq $true) { 49 | If (!(Test-Path -Path "$PathRoot\$Day")) { 50 | New-Item -Path $PathRoot -Name $Day -ItemType Directory 51 | } 52 | Write-Host "Move $($file.FullName) to $PathRoot\$Day" 53 | Move-Item -Path $file.FullName -Destination "$PathRoot\$Day" 54 | } else { 55 | } 56 | } else { 57 | Write-Host "if not in debug mode, would Move $($file.FullName) to $PathRoot\$Day" 58 | } 59 | } 60 | $VerbosePreference = 'SilentlyContinue' #$VerbosePreferenceBAK 61 | -------------------------------------------------------------------------------- /Misc/New-LocalUserAsAdmin.ps1: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | #.SYNOPSIS 3 | # New-LocalUserAsAdmin.ps1 4 | # Create a local user account if it does not exist and prevent the user from changing the password 5 | # Set the local user account to expire in a specified number of hours 6 | # Add the local user account to the local Administrators group. 7 | #.PARAMETER UserID 8 | # Specifies the User ID (User Name) to create or update 9 | #.PARAMETER GroupName 10 | # Specifies the name of the local user group to add the user to 11 | #.PARAMETER PasswordNeverExpires 12 | # Specifies the if the password should expire 13 | #.PARAMETER AccountExpiresInHours 14 | # Specifies the number of hours the account will be active until it expires 15 | #.EXAMPLE 16 | # New-LocalUserAsAdmin.ps1 -AccountExpiresInHours 6 -UserID Chad 17 | #.NOTES 18 | # - 2021/02/17 by Chad.Simmons@CatapultSystems.com - added support for PasswordNeverExpires and more 19 | # - 2021/02/03 by Chad.Simmons@CatapultSystems.com - Created 20 | ################################################################################ 21 | 22 | param ( 23 | [Parameter()][ValidatePattern('^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$')][string]$UserID, 24 | [Parameter()][string]$GroupName = 'Administrators', 25 | [Parameter()][bool]$PasswordNeverExpires = $false, 26 | [Parameter()][ValidateRange(0,8760)][int16]$AccountExpiresInHours = 0 27 | ) 28 | If ([string]::IsNullOrEmpty($UserID)) { $UserID = 'LocalUser' } 29 | Else { $UserID = 'Local_' + $UserID } 30 | 31 | [string]$Password = "$($env:ComputerName + '-' + [string](Get-Date -Format 'yyyy-MM-dd'))" 32 | [System.Security.SecureString]$Password = ConvertTo-SecureString -String $Password -AsPlainText -Force 33 | 34 | If (-not(Get-LocalUser -Name "$UserID" -ErrorAction SilentlyContinue)) { 35 | Write-Verbose 'Creating local user' 36 | Try { $User = New-LocalUser -FullName 'Local Standard User' -Name "$UserID" -UserMayNotChangePassword -Password $Password } Catch { Throw $_ } 37 | } 38 | $User = Get-LocalUser -Name "$UserID" -ErrorAction SilentlyContinue 39 | If ($User) { 40 | If ($AccountExpiresInHours -eq 0) { Try { Write-Verbose 'Setting AccountExpires'; Set-LocalUser -Name "$UserID" -AccountNeverExpires } Catch { Throw $_ } } 41 | Else { Try { Write-Verbose 'Setting AccountExpires'; Set-LocalUser -Name "$UserID" -AccountExpires $((Get-Date).AddHours($ExpiresInHours)) } Catch { Throw $_ } } 42 | Try { Write-Verbose 'Setting PasswordNeverExpires'; Set-LocalUser -Name "$UserID" -PasswordNeverExpires $PasswordNeverExpires } Catch { Throw $_ } 43 | Try { Write-Verbose 'Enabling local user'; [void](Enable-LocalUser -Name "$UserID") } Catch { } #throw $_ } 44 | Try { Write-Verbose "Adding local user to $GroupName group"; Add-LocalGroupMember -Group "$GroupName" -Member "$UserID" -ErrorAction Stop; Write-Output "$UserID added to local $GroupName group" } 45 | Catch [Microsoft.PowerShell.Commands.MemberExistsException] { Write-Output "$UserID is a member of the local $GroupName group" } 46 | Catch { throw $_ } 47 | } Else { return 2 } 48 | -------------------------------------------------------------------------------- /Misc/Out-GridView_IISLog.ps1: -------------------------------------------------------------------------------- 1 | Function Out-GridViewIISLog ($File) { 2 | #.Synopsis 3 | # Convert IIS log file to CSV and display in a GridView 4 | #.LINK 5 | # Based on https://stevenaskwith.com/2012/05/22/parse-iis-log-files-with-powershell/ 6 | # Performance inspired by http://www.happysysadm.com/2014/10/reading-large-text-files-with-powershell.html 7 | ########################################################################################################### 8 | $Headers = @((Get-Content -Path $File -ReadCount 4 -TotalCount 4)[3].split(' ') | Where-Object { $_ -ne '#Fields:' }); 9 | Import-Csv -Delimiter ' ' -Header $Headers -Path $File | Where-Object { $_.date -notlike '#*' } | Out-GridView -Title "IIS log: $File"; 10 | }; 11 | Out-GridViewIISLog -File "C:\InetPub\Logs\LogFiles\W3SVC1\u_ex$(Get-Date -F 'yyMMdd').log" 12 | 13 | 14 | Function Out-GridViewIISLogEx { 15 | #.Synopsis 16 | # Convert IIS log file to CSV and display in a GridView 17 | #.LINK 18 | # Based on https://stevenaskwith.com/2012/05/22/parse-iis-log-files-with-powershell/ 19 | # Performance inspired by http://www.happysysadm.com/2014/10/reading-large-text-files-with-powershell.html 20 | ########################################################################################################### 21 | param ($File, $ContentLike, $ClientIPLike, $TCPPort, [switch]$Unique, 22 | [parameter()][ValidateSet('*','ccmhttp','SMS+CCM+5.0+TS','Microsoft+BITS','DeliveryOptimization')][string]$ClientUserAgent = '*' 23 | ) 24 | $Headers = @((Get-Content -Path $File -ReadCount 4 -TotalCount 4)[3].split(' ') | Where-Object { $_ -ne '#Fields:' }); 25 | $Content = Import-Csv -Delimiter ' ' -Header $Headers -Path $File | Where-Object { $_.date -notlike '#*' }; 26 | Write-Verbose -Message "Found $($Content.count) log lines" 27 | If (-not([string]::IsNullOrEmpty($ContentLike))) { $Content = $Content | Where-Object { $_.'cs-uri-stem' -like "$ContentLike"}; Write-Verbose -Message "Found $($Content.count) filtered log lines" }; 28 | If (-not([string]::IsNullOrEmpty($ClientIPLike))) { $Content = $Content | Where-Object { $_.'c-ip' -like "$ClientIPLike" }; Write-Verbose -Message "Found $($Content.count) filtered log lines" }; 29 | If (-not([string]::IsNullOrEmpty($TCPPort))) { $Content = $Content | Where-Object { $_.'s-port' -eq $TCPPort }; Write-Verbose -Message "Found $($Content.count) filtered log lines" }; 30 | If ($ClientUserAgent) { 31 | Switch ($ClientUserAgent) { 32 | 'ccmhttp' { $Content = $Content | Where-Object { $_.'cs(User-Agent)' -eq 'ccmhttp' } }; 33 | 'SMS+CCM+5.0+TS' { $Content = $Content | Where-Object { $_.'cs(User-Agent)' -eq 'SMS+CCM+5.0+TS' } }; 34 | 'Microsoft+BITS' { $Content = $Content | Where-Object { $_.'cs(User-Agent)' -like 'Microsoft+BITS*' } }; 35 | 'DeliveryOptimization' { $Content = $Content | Where-Object { $_.'cs(User-Agent)' -eq 'Microsoft Delivery Optimization/10.0' } }; 36 | Default {} 37 | }; 38 | Write-Verbose -Message "Found $($Content.count) filtered log lines" -Verbose 39 | }; 40 | If ($Unique) { $Content = $Content | Select-Object -Unique; Write-Verbose -Message "Found $($Content.count) unique log lines" -Verbose } Else { Write-Verbose -Message "Found $($Content.count) filtered log lines" -Verbose }; 41 | If ($Content.count -ne 0) { $Content | Out-GridView -Title "IIS log: $File" }; 42 | }; 43 | Out-GridViewIISLogEx -File "D:\Logs\IIS\W3SVC1\u_ex210218.log" -ClientUserAgent DeliveryOptimization -Unique -ContentLike '*KB*' -TCPPort 80 -ClientIPLike '10.10.10.*' 44 | -------------------------------------------------------------------------------- /Misc/Test-EncodeDecodeInBase64.ps1: -------------------------------------------------------------------------------- 1 | #.Synopsis 2 | # Encode and Decode text in Base64 3 | 4 | $strPassword = 'Same_as_Install_Account' 5 | If([string]::IsNullOrEmpty($strPassword)) { $strPassword = Read-Host 'Enter Password' } 6 | 7 | #$strPasswordIn64 = [System.Convert]::ToBase64String([System.Text.Encoding]::GetBytes($strPassword)) 8 | #$strPasswordFrom64 = [System.Text.Encoding]::GetString([System.Convert]::FromBase64String($strPasswordIn64)) 9 | 10 | $strPasswordIn64_Unicode = [System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($strPassword)) 11 | $strPasswordFrom64_Unicode = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($strPasswordIn64_Unicode)) 12 | 13 | $strPasswordIn64_UTF8 = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($strPassword)) 14 | $strPasswordFrom64_UTF8 = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($strPasswordIn64_UTF8)) 15 | 16 | $strPasswordIn64_UTF7 = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF7.GetBytes($strPassword)) 17 | $strPasswordFrom64_UTF7 = [System.Text.Encoding]::UTF7.GetString([System.Convert]::FromBase64String($strPasswordIn64_UTF7)) 18 | 19 | $strPasswordIn64_UTF32 = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF32.GetBytes($strPassword)) 20 | $strPasswordFrom64_UTF32 = [System.Text.Encoding]::UTF32.GetString([System.Convert]::FromBase64String($strPasswordIn64_UTF32)) 21 | 22 | 23 | Write-Host "Password Entered: $($strPassword)" 24 | #Write-Host "Password converted to Base64: $strPasswordIn64" 25 | #Write-Host "Password converted from Base64: $strPasswordFrom64" 26 | Write-Host "Password converted to Base64 (Unicode): $strPasswordIn64_Unicode" 27 | Write-Host "Password converted from Base64 (Unicode): $strPasswordFrom64_Unicode" 28 | Write-Host "Password converted to Base64 (UTF-8): $strPasswordIn64_UTF8" 29 | Write-Host "Password converted from Base64 (UTF-8): $strPasswordFrom64_UTF8" 30 | Write-Host "Password converted to Base64 (UTF-7): $strPasswordIn64_UTF7" 31 | Write-Host "Password converted from Base64 (UTF-7): $strPasswordFrom64_UTF7" 32 | Write-Host "Password converted to Base64 (UTF-32): $strPasswordIn64_UTF32" 33 | Write-Host "Password converted from Base64 (UTF-32): $strPasswordFrom64_UTF32" 34 | If ($strPassword -ne $strPasswordFrom64_Unicode) { throw "The decoded password does not match the original" } 35 | -------------------------------------------------------------------------------- /New-Script.cmd: -------------------------------------------------------------------------------- 1 | @Echo Off 2 | setlocal 3 | set myCustomVariable=myCustomValue 4 | REM #################################################################################################################### 5 | If /I "%1"=="/h" goto:about 6 | If /I "%1"=="/help" goto:about 7 | goto:Initialize 8 | :about 9 | echo ################################################################################################################### 10 | echo .Synopsis 11 | echo ScriptFileName.cmd 12 | echo A brief description of the function or script 13 | echo .Description 14 | echo A detailed description of the function or script 15 | echo .Parameter 16 | echo The description of a parameter 17 | echo .Example 18 | echo ScriptFileName.cmd -Parameter1 19 | echo A sample command that uses the function or script, optionally followed by sample output and a description 20 | echo .Link 21 | echo The name and/or URL of a related topic 22 | echo .NOTES 23 | echo This script is maintained at ?????????????????????????????????????????????????????????????????????????????????? 24 | echo Additional information about the function or script. 25 | echo ========== Keywords ========================= 26 | echo Keywords: ??? 27 | echo ========== Change Log History =============== 28 | echo - YYYY/MM/DD by name@contoso.com - ~updated description~ 29 | echo - YYYY/MM/DD by name@contoso.com - created 30 | echo ========== To Do / Proposed Changes ========= 31 | echo - #TODO: None 32 | echo ===== Additional References and Reading ===== 33 | echo - : https://domain.url 34 | echo ################################################################################################################### 35 | goto:eof 36 | :Initialize 37 | setlocal 38 | set ScriptPath=%~dp0 39 | set ScriptPath=%ScriptPath:~,-1% 40 | set LogFile=%ProgramData%\Logs\%~n0.Log 41 | If NOT EXIST %LogFile% (MkDir %ProgramData%\Logs & ECHO Timestamp,Status,Message > %LogFile%) 42 | goto:main 43 | 44 | :LogMessage 45 | :: .Synopsis - Write timestamped message to a file or the console 46 | :: .Parameter1 - [mandatory] Message to be logged (must be double-quoted if it contains spaces) 47 | :: .Parameter2 - [optional] Status (Info, Warn, Error) 48 | If [%1]==[] goto:eof 49 | If [%LogFile%]==[] ECHO [%DATE:~10,4%-%date:~4,2%-%date:~7,2% %TIME:~0,8%] %2 %1 50 | If NOT [%LogFile%]==[] ECHO %DATE:~10,4%-%date:~4,2%-%date:~7,2% %TIME:~0,8%,%2,%1 >> "%LogFile%" 51 | goto:eof 52 | 53 | :main 54 | Call:LogMessage "========== Starting script %~0" "INFO" 55 | 56 | 57 | 58 | ping 127.0.0.1 -n 1 59 | 60 | 61 | 62 | :end 63 | Call:LogMessage "========== Completed script %~0" "INFO" 64 | If NOT [%LogFile%]==[] echo Activity logged to %LogFile% 65 | 66 | :eof -------------------------------------------------------------------------------- /PowerShell/Microsoft.PowerShellISE_profile.ps1: -------------------------------------------------------------------------------- 1 | . Microsoft.PowerShell_profile.ps1 -------------------------------------------------------------------------------- /PowerShell/Microsoft.PowerShell_profile.ps1: -------------------------------------------------------------------------------- 1 | #Load Configuration Manager PowerShell Module 2 | #.Link http://blogs.technet.com/b/configmgrdogs/archive/2015/01/05/powershell-ise-add-on-to-connect-to-configmgr-connect-configmgr.aspx 3 | If ($null -ne $Env:SMS_ADMIN_UI_PATH) { 4 | Try { 5 | Write-Host "Importing ConfigMgr PowerShell Module..." 6 | Import-Module ((Split-Path $env:SMS_ADMIN_UI_PATH)+"\ConfigurationManager.psd1") 7 | Write-Host "Executed `"Import-module `'((Split-Path $env:SMS_ADMIN_UI_PATH)+"\ConfigurationManager.psd1")`'`"" 8 | $SiteCode = (Get-PSDrive -PSProvider CMSITE).Name 9 | Push-Location "$($SiteCode):\" 10 | #Dir 11 | Pop-Location 12 | Write-Host "Detected ConfigMgr Site of $SiteCode. Execute the command 'CD $($SiteCode):\' before running any ConfigMgr cmdlet" -ForegroundColor Green 13 | } Catch { 14 | Write-Error "Executing `"Import-module `'((Split-Path $env:SMS_ADMIN_UI_PATH)+"\ConfigurationManager.psd1")`'`"" 15 | } 16 | } 17 | 18 | Function Get-RegistryValues($key) { (Get-Item $key).GetValueNames() } #.Example Get-RegistryValues HKLM:\Software\Microsoft\Windows\CurrentVersion 19 | Function Get-RegistryValue($key, $value) { (Get-ItemProperty $key $value).$value } #.Example Get-RegistryValue 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion' RegisteredOwner 20 | Function Test-IsProcElevatedAdmin {[bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match 'S-1-5-32-544')} 21 | Function Test-IsAdminByRole {([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')} #http://blogs.technet.com/b/heyscriptingguy/archive/2011/05/11/check-for-admin-credentials-in-a-powershell-script.aspx 22 | (Get-Host).UI.RawUI.WindowTitle = "Windows PowerShell version $($PSVersionTable.PSVersion.ToString()) :: running as $env:USERDOMAIN\$env:USERNAME ($env:USERDNSDOMAIN)" 23 | If (Test-IsProcElevatedAdmin) { (Get-Host).UI.RawUI.WindowTitle = "$((Get-Host).UI.RawUI.WindowTitle) with elevated rights" } 24 | Clear 25 | "`nBitness:$env:Processor_architecture || PoSH Version:$($PSVersionTable.PSVersion.ToString()) || ExecutionPolicy:$(Get-ExecutionPolicy) || isAdmin:$(Test-IsProcElevatedAdmin)/$(Test-IsAdminByRole) || RunAs:$($env:USERDOMAIN)\$($env:USERNAME) ($env:USERDNSDOMAIN)" 26 | If([bool]!([Environment]::GetCommandLineArgs() -like '-NoProfile')) {write-host "Profile:$profile"} else {"Profile was Used:False"} 27 | "Command Line Args: $([Environment]::GetCommandLineArgs())" 28 | Write-Host $('='*(($([Environment]::GetCommandLineArgs())).length+19)) -ForegroundColor White -BackgroundColor DarkGreen 29 | If ($null -ne $Env:SMS_ADMIN_UI_PATH) { Write-Host "Detected ConfigMgr Site of $SiteCode. Execute the command 'CD $($SiteCode):\' before running any ConfigMgr cmdlet" } 30 | If (Test-IsProcElevatedAdmin) { 31 | Write-Host 'PowerShell is running with Elevated Administrative rights (Run As Administrator)' 32 | } else { Write-Host 'PowerShell is NOT running with Elevated Administrative rights (Run As Administrator)' 33 | } 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Welcome to Chad's public scripts 2 | 3 | These scripts are focused on Windows management, particularly with ConfigMgr, Intune, WSUS, MDT, etc. 4 | 5 | Please feel free to submit issues, pull requests, etc. 6 | -------------------------------------------------------------------------------- /Upgrade-Windows/AppDeployToolkit.stub: -------------------------------------------------------------------------------- 1 | Download the PowerShell Application Deployment Toolkit from GitHub -------------------------------------------------------------------------------- /Windows Drivers/Extract-Drivers.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | If /I [%1]==[/h] goto:Help 4 | If /I [%1]==[-h] goto:Help 5 | If /I [%1]==[/help] goto:Help 6 | If /I [%1]==[-help] goto:Help 7 | goto:Begin 8 | :Help 9 | echo =============================================================================== 10 | echo =============================================================================== 11 | echo .Synopsis 12 | echo Stage Windows hardware drivers in the driver store 13 | echo .Description 14 | echo using Robocopy.exe, copy drivers from a Drivers.wim to the script's directory 15 | echo .Functionality 16 | echo Hardware Driver staging 17 | echo .Parameters 18 | echo [/h] [/help] display this help information 19 | echo .Notes 20 | echo === References and Sources === 21 | echo https://learn.microsoft.com/en-us/windows-hardware/drivers/install 22 | echo https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/pnputil 23 | echo https://utilizewindows.com/stage-a-driver-in-windows-7 24 | echo https://technet.microsoft.com/en-us/library/cc772036.aspx 25 | echo https://technet.microsoft.com/en-us/library/cc753716.aspx 26 | echo === Change Log History === 27 | echo 2023/05/09 by Chad.Simmons@Quisitive.com - Updated help section 28 | echo 2020/10/01 by Chad.Simmons@CatapultSystems.com - Added quotes to all file paths 29 | echo 2020/08/28 by Chad.Simmons@CatapultSystems.com - Created 30 | echo ================================================================================ 31 | goto:eof 32 | 33 | :Begin 34 | SET SourceDir=%~dp0 35 | SET SourceDir=%SourceDir:~,-1% 36 | 37 | If Exist "%SourceDir%\Drivers.wim" goto:MountWIM 38 | SET StageDir=%SourceDir% 39 | GOTO:ExtractDrivers 40 | 41 | :MountWIM 42 | SET StageDir=%SystemDrive%\_DriversWIM 43 | mkdir "%StageDir%" 44 | DISM.exe /Mount-Wim /WimFile:"%SourceDir%\Drivers.wim" /index:1 /MountDir:"%StageDir%" /ReadOnly 45 | 46 | :ExtractDrivers 47 | If Exist "%SourceDir%\Drivers.wim" Robocopy.exe "%StageDir%" "%SourceDir%" /e 48 | SET rc=%errorlevel% 49 | SET rc=0 50 | 51 | :END 52 | If Exist "%SourceDir%\Drivers.wim" DISM.exe /Unmount-Wim /MountDir:"%StageDir%" /Discard 53 | If Exist "%StageDir%" RMDir "%StageDir%" 54 | 55 | EXIT /b %rc% -------------------------------------------------------------------------------- /Windows Drivers/Remove-DellTouchpad/Remove-DellTouchPad.cmd: -------------------------------------------------------------------------------- 1 | @Echo off 2 | Echo Removing Dell TouchPad driver (Device ID ACPI\VEN_DLL&DEV_06DB) 3 | %~dp0devcon.exe remove "ACPI\VEN_DLL&DEV_06DB" 4 | Echo Please restart the computer to make the change effective. -------------------------------------------------------------------------------- /Windows Drivers/Remove-DellTouchpad/devcon.exe.stub: -------------------------------------------------------------------------------- 1 | Stub file to be replaced by the actual file -------------------------------------------------------------------------------- /Windows Drivers/Stage-Drivers.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | If /I [%1]==[/h] goto:Help 4 | If /I [%1]==[-h] goto:Help 5 | If /I [%1]==[/help] goto:Help 6 | If /I [%1]==[-help] goto:Help 7 | goto:Begin 8 | :Help 9 | echo =============================================================================== 10 | echo =============================================================================== 11 | echo .Synopsis 12 | echo Stage Windows hardware drivers in the driver store 13 | echo .Description 14 | echo using PNPUtil.exe, add hardware drivers for Microsoft Windows 11 / 10 / 8.1 / 8 / 7 to the Windows Drivers Store 15 | echo If Drivers.wim exists, mount it before running PNPUtil.exe and unmount it afterwards 16 | echo .Functionality 17 | echo Hardware Driver staging 18 | echo .Parameters 19 | echo [/h] [/help] display this help information 20 | echo .Notes 21 | echo === References and Sources === 22 | echo https://learn.microsoft.com/en-us/windows-hardware/drivers/install 23 | echo https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/pnputil 24 | echo https://utilizewindows.com/stage-a-driver-in-windows-7 25 | echo https://technet.microsoft.com/en-us/library/cc772036.aspx 26 | echo https://technet.microsoft.com/en-us/library/cc753716.aspx 27 | echo === Change Log History === 28 | echo 2023/05/10 by Chad.Simmons@Quisitive.com - Updated help section; added PnPutil logging; Echo return code(s) 29 | echo 2020/10/01 by Chad.Simmons@CatapultSystems.com - Added quotes to all file paths 30 | echo 2020/08/28 by Chad.Simmons@CatapultSystems.com - Created 31 | echo ================================================================================ 32 | goto:eof 33 | 34 | :Begin 35 | SET SourceDir=%~dp0 36 | SET SourceDir=%SourceDir:~,-1% 37 | 38 | If Exist "%SourceDir%\Drivers.wim" goto:MountWIM 39 | SET StageDir=%SourceDir% 40 | GOTO:InstallDrivers 41 | 42 | :MountWIM 43 | SET StageDir=%SystemDrive%\_DriversWIM 44 | mkdir "%StageDir%" 45 | DISM.exe /Mount-Wim /WimFile:"%SourceDir%\Drivers.wim" /index:1 /MountDir:"%StageDir%" /ReadOnly 46 | GOTO:InstallDrivers 47 | 48 | 49 | :InstallDrivers 50 | REM drivers in the mounted WIM are being injected into the offline image 51 | REM DISM.exe /Image:%OSDTargetSystemDrive%\ /Add-Driver /Driver:%StageDir% /Recurse /logpath:%_SMSTSMDataPath%\Drivers\dism.log 52 | 53 | REM Export an inventory of current drivers 54 | PowerShell.exe -NoProfile -Command "Get-WmiObject Win32_PnPSignedDriver | Select-Object Manufacturer, DriverProviderName, FriendlyName, DeviceName, DriverVersion, DriverDate, InfName, IsSigned, DeviceID, Description | Sort-Object DeviceID | Export-Csv -NoTypeInformation -Path $($env:Temp + '\DriverInventory.before.tmp'); Copy-Item -Path $($env:Temp + '\DriverInventory.before.tmp') -Destination $('C:\Windows\CCM\Logs\DriverInventory.'+$(Get-Date -Format 'yyyyMMdd_HHmmss')+'.csv')" 55 | REM PnPutil.exe /enum-drivers > "%Temp%\Enum-Drivers_BeforeImport.log" 56 | 57 | REM install/update drivers on any matching devices 58 | PnPutil.exe /add-driver "%StageDir%\*.inf" /subdirs /install >> "%WinDir%\CCM\Logs\Stage-Drivers.log" 59 | SET rc=%errorlevel% 60 | echo PNPUtil.exe completed with exit code %rc% >> "%WinDir%\CCM\Logs\Stage-Drivers.log" 61 | 62 | REM Export an inventory of drivers 63 | PowerShell.exe -NoProfile -Command "Get-WmiObject Win32_PnPSignedDriver | Select-Object Manufacturer, DriverProviderName, FriendlyName, DeviceName, DriverVersion, DriverDate, InfName, IsSigned, DeviceID, Description | Sort-Object DeviceID | Export-Csv -NoTypeInformation -Path $($env:Temp + '\DriverInventory.after.tmp'); Copy-Item -Path $($env:Temp + '\DriverInventory.after.tmp') -Destination $('C:\Windows\CCM\Logs\DriverInventory.'+$(Get-Date -Format 'yyyyMMdd_HHmmss')+'.csv')" 64 | REM PnPutil.exe /enum-drivers > "%Temp%\Enum-Drivers_AfterImport.log" 65 | 66 | :UnmountWIM 67 | If Exist "%SourceDir%\Drivers.wim" DISM.exe /Unmount-Wim /MountDir:"%StageDir%" /Discard 68 | If Exist "%StageDir%" RMDir "%StageDir%" 69 | 70 | 71 | :END 72 | REM TODO: Create log of exit actions, code, etc. 73 | 74 | REM https://www.sysmansquad.com/2020/05/15/modern-driver-management-with-the-administration-service 75 | If [%rc%]==[259] SET rc=3010 76 | 77 | REM if the before and after driver inventory has changed a reboot MAY be required, thus return success pending restart 78 | FC.exe "%TEMP%\DriverInventory.before.tmp" "%TEMP%\DriverInventory.after.tmp" 79 | If [%errorlevel%]==[1] SET rc=3010 80 | del /q "%TEMP%\DriverInventory.before.tmp" 81 | del /q "%TEMP%\DriverInventory.after.tmp" 82 | 83 | echo Script %~nx0 completed with exit code %rc% >> "%WinDir%\CCM\Logs\Stage-Drivers.log" 84 | EXIT /b %rc% -------------------------------------------------------------------------------- /Windows Drivers/Update-DellDriversFromInternet.cmd: -------------------------------------------------------------------------------- 1 | ::Run Dell Command | Update Version 3.1.1 to update drivers 2 | ::Requires https://www.dell.com/support/article/en-us/sln311129/dell-command-update?lang=en 3 | START /wait "Updating Dell drivers..." \dcu-cli.exe /applyUpdates -reboot=disable 4 | SET ReturnCode=%errorlevel% 5 | :: ===== Process Return Code ===== 6 | :: https://www.dell.com/support/manuals/us/en/04/command-update/dellcommandupdate_3.1.1_ug/command-line-interface-error-codes?guid=guid-f39c91a1-a1ce-4130-be73-8d6fae2ccc5f&lang=en-us 7 | :: Decimal ERROR_NAME: Error description 8 | :: 0 ERROR_SUCCESS: Success, no reboot required 9 | :: 1 A reboot was required from the execution of an operation 10 | :: 5 A reboot was pending from a previous operation 11 | :: 7 The application does not support the current system model 12 | :: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d 13 | :: https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes 14 | :: 999 One of several Fail FastRetry return codes know by ConfigMgr 15 | :: 10 ERROR_BAD_ENVIRONMENT 16 | :: Set Default to 999 / Retry 17 | SET FinalReturnCode=999 18 | If %ReturnCode%==0 SET FinalReturnCode=0 19 | If %ReturnCode%==1 SET FinalReturnCode=3010 20 | If %ReturnCode%==3 SET FinalReturnCode=10 21 | If %ReturnCode%==5 SET FinalReturnCode=3010 22 | If %ReturnCode%==7 SET FinalReturnCode=10 23 | If %ReturnCode%==500 SET FinalReturnCode=0 24 | EXIT /b %FinalReturnCode% -------------------------------------------------------------------------------- /Windows Drivers/Update-Drivers.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal 3 | If /I [%1]==[/h] goto:Help 4 | If /I [%1]==[-h] goto:Help 5 | If /I [%1]==[/help] goto:Help 6 | If /I [%1]==[-help] goto:Help 7 | goto:Begin 8 | :Help 9 | echo =============================================================================== 10 | echo =============================================================================== 11 | echo .Synopsis 12 | echo Install/Upgrade Windows hardware drivers 13 | echo .Description 14 | echo using PNPUtil.exe, install/update hardware drivers for Microsoft Windows 11 / 10 / 8.1 / 8 / 7 15 | echo If Drivers.wim exists, mount it before running PNPUtil.exe and unmount it afterwards 16 | echo .Functionality 17 | echo Hardware Driver Upgrade 18 | echo .Parameters 19 | echo [/h] [/help] display this help information 20 | echo .Notes 21 | echo === References and Sources === 22 | echo https://learn.microsoft.com/en-us/windows-hardware/drivers/install 23 | echo https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/pnputil 24 | echo https://utilizewindows.com/stage-a-driver-in-windows-7 25 | echo https://technet.microsoft.com/en-us/library/cc772036.aspx 26 | echo https://technet.microsoft.com/en-us/library/cc753716.aspx 27 | echo === Change Log History === 28 | echo 2023/05/09 by Chad.Simmons@Quisitive.com - Updated help section 29 | echo 2020/10/01 by Chad.Simmons@CatapultSystems.com - Added quotes to all file paths 30 | echo 2020/09/09 by Chad.Simmons@CatapultSystems.com - Added script header and exit code 3010 logic 31 | echo 2020/08/28 by Chad.Simmons@CatapultSystems.com - Created 32 | echo ================================================================================ 33 | goto:eof 34 | 35 | :Begin 36 | SET SourceDir=%~dp0 37 | SET SourceDir=%SourceDir:~,-1% 38 | 39 | If Exist "%SourceDir%\Drivers.wim" goto:MountWIM 40 | SET StageDir=%SourceDir% 41 | GOTO:InstallDrivers 42 | 43 | :MountWIM 44 | SET StageDir=%SystemDrive%\_DriversWIM 45 | mkdir "%StageDir%" 46 | DISM.exe /Mount-Wim /WimFile:"%SourceDir%\Drivers.wim" /index:1 /MountDir:"%StageDir%" /ReadOnly 47 | GOTO:InstallDrivers 48 | 49 | 50 | :InstallDrivers 51 | REM drivers in the mounted WIM are being injected into the offline image 52 | REM DISM.exe /Image:%OSDTargetSystemDrive%\ /Add-Driver /Driver:%StageDir% /Recurse /logpath:%_SMSTSMDataPath%\Drivers\dism.log 53 | 54 | REM Export an inventory of current drivers 55 | PowerShell.exe -NoProfile -Command "Get-WmiObject Win32_PnPSignedDriver | Select-Object Manufacturer, DriverProviderName, FriendlyName, DeviceName, DriverVersion, DriverDate, InfName, IsSigned, DeviceID, Description | Sort-Object DeviceID | Export-Csv -NoTypeInformation -Path $($env:Temp + '\DriverInventory.before.tmp'); Copy-Item -Path $($env:Temp + '\DriverInventory.before.tmp') -Destination $('C:\Windows\CCM\Logs\DriverInventory.'+$(Get-Date -Format 'yyyyMMdd_HHmmss')+'.csv')" 56 | REM PnPutil.exe /enum-drivers > "%Temp%\Enum-Drivers_BeforeImport.log" 57 | 58 | REM install/update drivers on any matching devices 59 | PnPutil.exe /add-driver "%StageDir%\*.inf" /subdirs /install >> "%WinDir%\CCM\Logs\Update-Drivers.log" 60 | SET rc=%errorlevel% 61 | echo PNPUtil.exe completed with exit code %rc% >> "%WinDir%\CCM\Logs\Update-Drivers.log" 62 | 63 | REM Export an inventory of drivers 64 | PowerShell.exe -NoProfile -Command "Get-WmiObject Win32_PnPSignedDriver | Select-Object Manufacturer, DriverProviderName, FriendlyName, DeviceName, DriverVersion, DriverDate, InfName, IsSigned, DeviceID, Description | Sort-Object DeviceID | Export-Csv -NoTypeInformation -Path $($env:Temp + '\DriverInventory.after.tmp'); Copy-Item -Path $($env:Temp + '\DriverInventory.after.tmp') -Destination $('C:\Windows\CCM\Logs\DriverInventory.'+$(Get-Date -Format 'yyyyMMdd_HHmmss')+'.csv')" 65 | REM PnPutil.exe /enum-drivers > "%Temp%\Enum-Drivers_AfterImport.log" 66 | 67 | :UnmountWIM 68 | If Exist "%SourceDir%\Drivers.wim" DISM.exe /Unmount-Wim /MountDir:"%StageDir%" /Discard 69 | If Exist "%StageDir%" RMDir "%StageDir%" 70 | 71 | 72 | :END 73 | REM TODO: Create log of exit actions, code, etc. 74 | 75 | REM https://www.sysmansquad.com/2020/05/15/modern-driver-management-with-the-administration-service 76 | If [%rc%]==[259] SET rc=3010 77 | 78 | REM if the before and after driver inventory has changed a reboot MAY be required, thus return success pending restart 79 | FC.exe "%TEMP%\DriverInventory.before.tmp" "%TEMP%\DriverInventory.after.tmp" 80 | If [%errorlevel%]==[1] SET rc=3010 81 | del /q "%TEMP%\DriverInventory.before.tmp" 82 | del /q "%TEMP%\DriverInventory.after.tmp" 83 | 84 | echo Script %~nx0 completed with exit code %rc% >> "%WinDir%\CCM\Logs\Update-Drivers.log" 85 | EXIT /b %rc% -------------------------------------------------------------------------------- /Windows Drivers/Update-WindowsDriversFromMicrosoftUpdate.ps1: -------------------------------------------------------------------------------- 1 | #http://rzander.azurewebsites.net/script-to-install-or-update-drivers-directly-from-microsoft-catalog/ 2 | $UpdateSvc = New-Object -ComObject Microsoft.Update.ServiceManager 3 | $UpdateSvc.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"") 4 | 5 | (New-Object -ComObject Microsoft.Update.ServiceManager).Services 6 | 7 | $Session = New-Object -ComObject Microsoft.Update.Session 8 | $Searcher = $Session.CreateUpdateSearcher() 9 | 10 | $Searcher.ServiceID = '7971f918-a847-4430-9279-4a52d1efe18d' 11 | $Searcher.SearchScope = 1 # MachineOnly 12 | $Searcher.ServerSelection = 3 # Third Party 13 | $Criteria = "IsInstalled=0 and Type='Driver'" 14 | 15 | Write-Host('Searching Driver-Updates...') -Fore Green 16 | $SearchResult = $Searcher.Search($Criteria) 17 | $Updates = $SearchResult.Updates 18 | 19 | $Exclude = @('ThinkPad P50 System Firmware 1.48') 20 | $Updates = $Updates | Where-Object { $_.DriverModel -notin $Exclude } 21 | #Show available Drivers... 22 | $Updates | Select-Object DriverModel, Title, DriverVerDate, DriverClass, DriverManufacturer | Sort-Object DriverModel, Title | Format-Table -AutoSize 23 | $Updates.Count 24 | 25 | $UpdatesToDownload = New-Object -Com Microsoft.Update.UpdateColl 26 | $updates | ForEach-Object { $UpdatesToDownload.Add($_) | out-null } 27 | Write-Host('Downloading Drivers...') -Fore Green 28 | $UpdateSession = New-Object -Com Microsoft.Update.Session 29 | $Downloader = $UpdateSession.CreateUpdateDownloader() 30 | $Downloader.Updates = $UpdatesToDownload 31 | $Downloader.Download() 32 | 33 | $UpdatesToInstall = New-Object -Com Microsoft.Update.UpdateColl 34 | $updates | ForEach-Object { if($_.IsDownloaded) { $UpdatesToInstall.Add($_) | out-null } } 35 | 36 | Write-Host('Installing Drivers...') -Fore Green 37 | $Installer = $UpdateSession.CreateUpdateInstaller() 38 | $Installer.Updates = $UpdatesToInstall 39 | $InstallationResult = $Installer.Install() 40 | If ($InstallationResult.RebootRequired) { 41 | Write-Host('Reboot required! please reboot now..') -ForegroundColor Red 42 | } else { Write-Host('Done') -ForegroundColor Green } 43 | -------------------------------------------------------------------------------- /Windows Installer/CSI_ExtractMSIGUIDAndIcons.TXT: -------------------------------------------------------------------------------- 1 | '* COPYRIGHT NOTICE: This script is Copyrighted by Synaptic Fireworks, LLC 2 | '* 3 | '* This copyright notice and all comments in the script must remain intact. 4 | '* 5 | '* For publicly available scripts: 6 | '* If you downloaded this script from CSI-Windows.com or DesktopEngineer.com 7 | '* then you may use it in your organization. 8 | '* 9 | '* For privately scripts (including enhanced versions of public scripts): 10 | '* If this script is not available publicly and you received it directly 11 | '* from CSI-Windows.com as a result of training, a conference or personal 12 | '* contact with staff, then you are allowed to use the script in your 13 | '* organization. 14 | '* 15 | '* Regardless of this script's public/private availability, 16 | '* no public or private redistribution of this code is allowed - this 17 | '* includes the entire script or parts of the script code. This 18 | '* includes, but is not limited to email, posting to websites, blogs 19 | '* or forums, CDs, flashdrives or any other means. 20 | '* 21 | '* Posting links to the script's homepage on CSI-Windows.com is allowed. 22 | '* -------------------------------------------------------------------------------- /Windows Installer/Get-MSIFileInformation.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .Example 3 | .\Get-MSIFileInformation.ps1 -Path "D:\Source$\Apps\7-zip\7z920-x64.msi" -Property ProductCode 4 | .Link 5 | https://msendpointmgr.com/2014/08/22/how-to-get-msi-file-information-with-powershell/ 6 | https://github.com/NickolajA/PowerShell/blob/master/ConfigMgr/Application/Get-MSIFileInformation.ps1 7 | #> 8 | 9 | param( 10 | [parameter(Mandatory=$true)] 11 | [IO.FileInfo]$Path, 12 | [parameter(Mandatory=$true)] 13 | [ValidateSet("ProductCode","ProductVersion","ProductName")] 14 | [string]$Property 15 | ) 16 | try { 17 | $WindowsInstaller = New-Object -ComObject WindowsInstaller.Installer 18 | $MSIDatabase = $WindowsInstaller.GetType().InvokeMember("OpenDatabase","InvokeMethod",$Null,$WindowsInstaller,@($Path.FullName,0)) 19 | $Query = "SELECT Value FROM Property WHERE Property = '$($Property)'" 20 | $View = $MSIDatabase.GetType().InvokeMember("OpenView","InvokeMethod",$null,$MSIDatabase,($Query)) 21 | $View.GetType().InvokeMember("Execute", "InvokeMethod", $null, $View, $null) 22 | $Record = $View.GetType().InvokeMember("Fetch","InvokeMethod",$null,$View,$null) 23 | $Value = $Record.GetType().InvokeMember("StringData","GetProperty",$null,$Record,1) 24 | return $Value 25 | } 26 | catch { 27 | Write-Output $_.Exception.Message 28 | } -------------------------------------------------------------------------------- /Windows Installer/Get-MSIFileInformationEx.ps1: -------------------------------------------------------------------------------- 1 | #Get-MSIFileInformationEx.ps1 2 | #by Chad.Simmons@CatapultSystems.com 3 | #based on https://github.com/NickolajA/PowerShell/blob/master/ConfigMgr/Application/Get-MSIFileInformation.ps1 4 | 5 | #TODO: proper header and inline comments 6 | #TODO: extract icons like CSI_ExtractMSIGUIDAndIcons.vbs 7 | param( 8 | [parameter(Mandatory=$true)][ValidateScript({Test-Path -LiteralPath $_ -PathType Leaf})][string]$Path, #e:\xfer\anyconnect-win-4.9.05042-core-vpn-predeploy-k9.msi 9 | [parameter(Mandatory=$false)][ValidateSet('ProductCode','ProductVersion','ProductName','*')][string]$Property 10 | ) 11 | 12 | #get the $Path item because the COM object requires a full path 13 | $MSIFile = Get-Item -Path $Path 14 | 15 | #Set list of MSI Property Names to get if none specified 16 | If ($Property -eq '*' -or $Property -eq '' -or $null -eq $Property) { 17 | $MSIPropertyNames = @('Manufacturer', 'ProductName', 'ProductVersion', 'ProductVersionMarketing', 'ProductLanguage', 'ProductCode', 'UpgradeCode', 'Author', 'Comments') 18 | } Else { 19 | $MSIPropertyNames = @($Property) 20 | } 21 | try { 22 | $WindowsInstaller = New-Object -ComObject WindowsInstaller.Installer 23 | $MSIDatabase = $WindowsInstaller.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $Null, $WindowsInstaller, @($MSIFile.FullName, 0)) 24 | } catch { 25 | Write-Output $_.Exception.Message; break 26 | } 27 | $MSIProperties = [ordered]@{} 28 | ForEach ($PropertyName in $MSIPropertyNames) { 29 | try { 30 | $View = $MSIDatabase.GetType().InvokeMember("OpenView", "InvokeMethod", $null, $MSIDatabase, "SELECT Value FROM Property WHERE Property = '$($PropertyName)'") 31 | $View.GetType().InvokeMember("Execute", "InvokeMethod", $null, $View, $null) 32 | $Record = $View.GetType().InvokeMember("Fetch","InvokeMethod",$null,$View,$null) 33 | $Value = $Record.GetType().InvokeMember("StringData", "GetProperty", $null, $Record, 1) 34 | } catch {} 35 | $MSIProperties.Add($PropertyName, $Value) 36 | Remove-Variable -Name View, Record, Value -ErrorAction SilentlyContinue 37 | } 38 | $MSIProperties.Add('FileFullPath', $MSIFile) 39 | $MSIProperties.Add('FilePath', $MSIFile.Directory) 40 | $MSIProperties.Add('FileName', $MSIFile.Name) 41 | $MSIProperties.Add('FileSizeInBytes', $MSIFile.Length) 42 | $MSIProperties.Add('FileSizeInMB', [math]::Round($($MSIFile.Length) / 1MB, 2)) 43 | $MSIProperties 44 | 45 | <# 46 | #TODO: table with optional variables: Directory -> Directory = INSTALLDIR, Directory, 'Directory Parent', 'DefaultDir' 47 | $View = $MSIDatabase.GetType().InvokeMember("OpenView", "InvokeMethod", $null, $MSIDatabase, "SELECT Directory FROM Directory WHERE Directory = 'INSTALLDIR'") 48 | $View.GetType().InvokeMember("Execute", "InvokeMethod", $null, $View, $null) 49 | $Record = $View.GetType().InvokeMember("Fetch", "InvokeMethod", $null, $View, $null) 50 | $Value = $Record.GetType().InvokeMember("StringData", "GetProperty", $null, $Record, 1) 51 | $Value 52 | $MSIProperties.Add($PropertyName, $Value) 53 | 54 | #TODO: table with 1+ rows: Upgrade -> UpgradeCode, VersionMin, VersionMax, Language, Attributes, Remove, ActionProperty 55 | $View = $MSIDatabase.GetType().InvokeMember("OpenView", "InvokeMethod", $null, $MSIDatabase, "SELECT VersionMin FROM Upgrade") 56 | $View.GetType().InvokeMember("Execute", "InvokeMethod", $null, $View, $null) 57 | $Record = $View.GetType().InvokeMember("Fetch", "InvokeMethod", $null, $View, $null) 58 | $Value = $Record.GetType().InvokeMember("StringData", "GetProperty", $null, $Record, 1) 59 | $Value 60 | #> -------------------------------------------------------------------------------- /Windows Installer/Get-MSIinstalls.vbs: -------------------------------------------------------------------------------- 1 | 'from Office scrubber vbs 2 | Set oMsi = CreateObject("WindowsInstaller.Installer") 3 | Sub CheckForLegacyProducts 4 | Const OLEGACY = "78E1-11D2-B60F-006097C998E7}.6000-11D3-8CFE-0050048383C9}.6000-11D3-8CFE-0150048383C9}.BDCA-11D1-B7AE-00C04FB92F3D}.6D54-11D4-BEE3-00C04F990354}" 5 | Dim Product 6 | 7 | 'Set safe default 8 | fLegacyProductFound = True 9 | 10 | For Each Product in oMsi.Products 11 | wscript.echo Product 12 | wscript.echo Product.ProductInfo 13 | If Len(Product) = 38 Then 14 | 'Handle O09 - O11 Products 15 | If InStr(OLEGACY, UCase(Right(Product, 28))) > 0 Then 16 | 'Found legacy Office product. Keep flag in default and exit 17 | Exit Sub 18 | End If 19 | If UCase(Right(Product,PRODLEN)) = OFFICEID Then 20 | Select Case Mid(Product,4,2) 21 | Case "12", "14" 22 | wscript.echo "Found legacy Office product." 23 | 'Exit Sub 24 | Case Else 25 | End Select 26 | End If 27 | End If '38 28 | Next 'Product 29 | fLegacyProductFound = False 30 | 31 | End Sub 'CheckForLegacyProducts 32 | 33 | CheckForLegacyProducts -------------------------------------------------------------------------------- /Windows Installer/Get-MSUFileInfo_Function.ps1: -------------------------------------------------------------------------------- 1 | function Get-MSUFileInfo { 2 | <# 3 | .SYNOPSIS 4 | Get MSU Package Information 5 | 6 | .DESCRIPTION 7 | retrieve all available information on an MSU file. 8 | 9 | .PARAMETER FileName 10 | A description of the FileName parameter. 11 | 12 | .NOTES 13 | =========================================================================== 14 | Created with: SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.145 15 | Created on: 3/12/2018 6:41 AM 16 | Created by: Mick Pletcher 17 | Filename: Get-MSUFileInfo.ps1 18 | https://github.com/MicksITBlogs/PowerShell/blob/master/Get-MSUFileInfo.ps1 19 | =========================================================================== 20 | #> 21 | 22 | [CmdletBinding()] 23 | param 24 | ( 25 | [System.IO.FileInfo]$FileName 26 | ) 27 | 28 | #Get the path of this script 29 | $RelativePath = (split-path $SCRIPT:MyInvocation.MyCommand.Path -parent) + "\" 30 | #full path of expand.exe 31 | $Executable = Join-Path -Path $env:windir -ChildPath "System32\expand.exe" 32 | #Directory to place expanded file(s) 33 | $Directory = Join-Path -Path $RelativePath -ChildPath Expanded -ErrorAction SilentlyContinue 34 | #Delete the Expanded directory and all contents if it exists 35 | Remove-Item -Path $Directory -Recurse -Force -ErrorAction SilentlyContinue 36 | #Create the Expanded directory 37 | New-Item -Path $Directory -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null 38 | #Parameters for the expand.exe 39 | $Parameters = '-F:*properties.txt' + [char]32 + [char]34 + $FileName.FullName + [char]34 + [char]32 + [char]34 + $Directory + [char]34 40 | #Expand the msu file 41 | $ErrCode = (Start-Process -FilePath $Executable -ArgumentList $Parameters -WindowStyle Hidden -Wait -Passthru).ExitCode 42 | #Define the file that contains information on the MSU 43 | $ExpandedFile = Get-ChildItem -Path $Directory -Filter *properties.txt 44 | #Create the object 45 | $MSUObject = New-Object System.Object 46 | $MSUObject | Add-Member -MemberType NoteProperty -Name AppliesTo -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Applies to*' }).split("=")[1].replace('"', '') 47 | $MSUObject | Add-Member -MemberType NoteProperty -Name BuildDate -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Build Date*' }).split("=")[1].replace('"', '') 48 | $MSUObject | Add-Member -MemberType NoteProperty -Name Company -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Company*' }).split("=")[1].replace('"', '') 49 | $MSUObject | Add-Member -MemberType NoteProperty -Name FileVersion -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*File Version*' }).split("=")[1].replace('"', '') 50 | $MSUObject | Add-Member -MemberType NoteProperty -Name InstallationType -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Installation Type*' }).split("=")[1].replace('"', '') 51 | $MSUObject | Add-Member -MemberType NoteProperty -Name InstallerEngine -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Installer Engine*' }).split("=")[1].replace('"', '') 52 | $MSUObject | Add-Member -MemberType NoteProperty -Name InstallerVersion -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Installer Version*' }).split("=")[1].replace('"', '') 53 | $MSUObject | Add-Member -MemberType NoteProperty -Name KBArticle -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*KB Article Number*' }).split("=")[1].replace('"', '') 54 | $MSUObject | Add-Member -MemberType NoteProperty -Name Language -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Language*' }).split("=")[1].replace('"', '') 55 | $MSUObject | Add-Member -MemberType NoteProperty -Name PackageType -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Package Type*' }).split("=")[1].replace('"', '') 56 | $MSUObject | Add-Member -MemberType NoteProperty -Name ProcessorArchitecture -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Processor Architecture*' }).split("=")[1].replace('"', '') 57 | $MSUObject | Add-Member -MemberType NoteProperty -Name ProductName -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Product Name*' }).split("=")[1].replace('"', '') 58 | $MSUObject | Add-Member -MemberType NoteProperty -Name SupportLink -Value (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Support Link*' }).split("=")[1].replace('"', '') 59 | #Delete the Expanded directory and all contents if it exists 60 | Remove-Item -Path $Directory -Recurse -Force -ErrorAction SilentlyContinue 61 | Return $MSUObject 62 | } -------------------------------------------------------------------------------- /Windows/Get-Uptime.ps1: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | #.SYNOPSIS 3 | # Get-Uptime.ps1 4 | # Report the time a local, remote, or list of remote Windows computers have 5 | # been running since their last restart/reboot/power on 6 | #.DESCRIPTION 7 | # This script generally requires administrative rights to remotely execute a 8 | # WMI get object command 9 | # 10 | # The entire script could be reduced to the following and still get the critical information 11 | # Get-WMIObject -Computer $env:ComputerName -Namespace root\CIMv2 -class Win32_OperatingSystem | Select-Object PSComputerName, LocalDateTime, LastBootUpTime, @{Name='UptimeMinutes'; Expression={ [int]([Management.ManagementDateTimeConverter]::ToDateTime($_.LocalDateTime)-[Management.ManagementDateTimeConverter]::ToDateTime($_.LastBootUpTime)).TotalMinutes }} 12 | #.PARAMETER ComputerName 13 | # comma separated list of computer name(s) to report against 14 | #.EXAMPLE 15 | # Get-Uptime.ps1 16 | # Report the up time details of the local computer 17 | #.EXAMPLE 18 | # Get-Uptime.ps1 -ComputerName $env:ComputerName, RemoteComputer1, RemoteComputer2 19 | # Report the up time details of the local computer and 2 remote computers 20 | #.NOTES 21 | # This script is maintained at https://github.com/ChadSimmons/Scripts 22 | # Additional information about the function or script. 23 | # ========== Keywords ========== 24 | # Keywords: reboot restart power on power cycle 25 | # ========== Change Log History ========== 26 | # - 2021/03/12 by Chad.Simmons@CatapultSystems.com - Created 27 | # - 2021/03/12 by Chad@ChadsTech.net - Created 28 | ################################################################################ 29 | [CmdletBinding()] 30 | param ([string[]]$ComputerName = $env:ComputerName) 31 | Function Get-Uptime { 32 | [cmdletbinding()] 33 | Param([Parameter(Mandatory = $true)][string[]]$ComputerName) 34 | Begin { 35 | $MyTimeZone = (Get-WmiObject -Computer $env:ComputerName -Namespace 'root\CIMv2' -Class 'Win32_OperatingSystem' -ErrorAction Stop -Property CurrentTimeZone).CurrentTimeZone 36 | Write-Output "My TimeZone is $MyTimeZone" 37 | } 38 | Process { 39 | $Report = @() 40 | $ComputerNameCount = $ComputerName.Count; $iCount = 0 41 | ForEach ($Computer in $ComputerName) { 42 | $iCount++ 43 | Write-Progress -Activity 'Connecting to remote computers' -Status "[$iCount / $ComputerNameCount] $Computer" 44 | $Uptime = New-Object -TypeName PSObject -Property $([ordered]@{ ComputerName = $Computer; Status = 'undefined'; UptimeMinutes = $null; UptimeHours = $null; UptimeDays = $null; LocalDateTime = $null; LastBootUpTime = $null; OSInstallDate = $null; CurrentTimeZone = $null; OSName = $null; OSVersion = $null; OSArchitecture = $null; }) 45 | try { 46 | $WMI = Get-WMIObject -Computer $Computer -Namespace 'root\CIMv2' -Class 'Win32_OperatingSystem' -ErrorAction Stop 47 | $Uptime.Status = $WMI.Status #'Connected' 48 | $Uptime.UptimeMinutes = [int]([Management.ManagementDateTimeConverter]::ToDateTime($WMI.LocalDateTime) - [Management.ManagementDateTimeConverter]::ToDateTime($WMI.LastBootUpTime)).TotalMinutes 49 | Write-Verbose -Message "Computer $Computer `t$($Uptime.UptimeMinutes) uptime minutes" 50 | $Uptime.UptimeHours = [math]::Round($Uptime.UptimeMinutes / 60, 1) 51 | $Uptime.UptimeDays = [math]::Round($Uptime.UptimeMinutes / 60 / 24, 1) 52 | $Uptime.LocalDateTime = [Management.ManagementDateTimeConverter]::ToDateTime($WMI.LocalDateTime) 53 | $Uptime.LastBootUpTime = [Management.ManagementDateTimeConverter]::ToDateTime($WMI.LastBootUpTime) 54 | $Uptime.OSInstallDate = [Management.ManagementDateTimeConverter]::ToDateTime($WMI.InstallDate) 55 | $Uptime.CurrentTimeZone = $WMI.CurrentTimeZone 56 | $Uptime.OSName = $WMI.Caption 57 | $Uptime.OSVersion = $WMI.Version 58 | $Uptime.OSArchitecture = $WMI.OSArchitecture 59 | } Catch { 60 | $Uptime.Status = 'Connection Failed' 61 | Write-Verbose -Message "Computer $Computer `tConnection Failed" 62 | } 63 | $Report += $Uptime 64 | } 65 | } 66 | End { 67 | Return $Report 68 | } 69 | } 70 | $global:UptimeData = @(Get-Uptime -ComputerName $ComputerName) 71 | If ($UptimeData.count -eq 1) { $UptimeData | Format-List } 72 | ElseIf ($UptimeData.count -gt 1) { $UptimeData | Format-Table * -AutoSize } 73 | Else { Write-Output 'No data returned' } 74 | Write-Host 'Uptime data object is $UptimeData' -------------------------------------------------------------------------------- /Windows/Set mobile network connections as non-metered by default.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ChadSimmons/Scripts/f7ee666abef230fe04c9d9f6e1ff5fd56c551f71/Windows/Set mobile network connections as non-metered by default.zip -------------------------------------------------------------------------------- /Windows/Set-TimeSyncOnWorkgroupComputer.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | ::https://learn.microsoft.com/en-us/windows-server/networking/windows-time-service/windows-time-service-tools-and-settings?tabs=config#command-line-parameters-for-w32time 3 | setlocal 4 | set timePeers=pool.ntp.org lab-dc1.lab.local 5 | w32tm /config /update /manualpeerlist:%timePeers% /syncfromflags:ALL 6 | sc config W32time start=delayed-auto 7 | sc stop W32time 8 | sc start W32time -------------------------------------------------------------------------------- /Windows/Update-MicrosoftStoreApps.ps1: -------------------------------------------------------------------------------- 1 | # Update-MicrosoftStoreApps.ps1 2 | # Attempt to force Microsoft Store applications to update 3 | # A user must be logged in 4 | # The computer must have Internet access unrestricted to Microsoft Store URLs / IPs 5 | 6 | # Get inventory of Microsoft Store apps from ConfigMgr WMI class 7 | Get-WmiObject -Query 'SELECT * FROM SMS_Windows8Application' -Namespace 'root\cimv2\sms' -ErrorAction SilentlyContinue 8 | 9 | # Set policy to allow Windows Update Agent to Internet content delivery network, not just an internal/WSUS source 10 | Set-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate' -Name 'DoNotConnectToWindowsUpdateInternetLocations' -Value 0 -Type DWORD -Force #Disable / Allow 11 | 12 | # Trigger Microsoft Store app updates scan 13 | $WmiObj = Get-WmiObject -Namespace 'root\CIMv2\mdm\dmmap' -Class 'MDM_EnterpriseModernAppManagement_AppManagement01' 14 | $result = $WmiObj.UpdateScanMethod() 15 | 16 | # exit with return code 17 | exit $result.ReturnValue 18 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-midnight --------------------------------------------------------------------------------