├── Intune
├── placeholder.txt
└── App Distribution
│ ├── Get-StoreAppInformation.ps1
│ └── Invoke-DownloadAppImage.ps1
├── ConfigMgr
├── OS Deployment
│ ├── Branding
│ │ ├── placeholder.txt
│ │ └── Wallpaper
│ │ │ ├── 4K
│ │ │ └── howto.txt
│ │ │ ├── img0.jpg
│ │ │ └── Modules
│ │ │ └── howto.txt
│ ├── Export-TSVariableValues.ps1
│ ├── Set-CMBootImageEnableCommandLineSupport.ps1
│ ├── Get-TSExecutionStatusForDevice.ps1
│ ├── Get-CMOSImageOfflineServicingSchedule.ps1
│ ├── Enable-UbuntuForWindows.ps1
│ ├── Start-DaRTRemoteViewer.ps1
│ └── Enable-CredentialGuard.ps1
├── Modules
│ ├── CM2012Module
│ │ ├── CM2012_0.1.psd1
│ │ └── CM2012_0.2.psd1
│ └── ConfigMgrMigration
│ │ └── ConfigMgrMigration.psd1
├── Software Updates
│ ├── CreateSoftwareUpdateGroup
│ │ ├── CreateSoftwareUpdateGroup.zip
│ │ └── CreateSoftwareUpdateGroup.xml
│ ├── Set-ADRDeploymentTime.ps1
│ ├── ConvertTo-CMSoftwareUpdate.ps1
│ ├── Add-CMWSUSScanRetryErrorCodes.ps1
│ ├── New-CMDeploymentPackage.ps1
│ └── Remove-CMSoftwareUpdateFromDeploymentPackage.ps1
├── Client & Devices
│ ├── Clean-CMClientCache.ps1
│ ├── Import-CMComputerInformation.ps1
│ ├── Get-CMDeviceModels.ps1
│ ├── Get-DeviceCollectionMembership.ps1
│ ├── Get-CMDeviceIPAddresses.ps1
│ └── Import-CMDevice.ps1
├── Application
│ ├── Get-MSIFileInformation.ps1
│ ├── Create-CMConsoleApplication.ps1
│ ├── ConvertFrom-CMApplicationCIUniqueID.ps1
│ ├── Add-CMApplicationRequirementRule.ps1
│ ├── Get-CMApplicationsRequirementPrimaryDevice.ps1
│ ├── Start-ApplicationDistribution.ps1
│ └── Get-CMApplicationWithDependency.ps1
├── Tools
│ ├── GetTSPackageReferenceTool
│ │ └── TSReference.xml
│ ├── GetMaintenanceWindow
│ │ └── MW.xml
│ ├── DellWarranty
│ │ └── DellWarranty.xml
│ ├── Invoke-AndroidAppWrapperTool.ps1
│ ├── StartRDPFromIP
│ │ └── Start-RDPFromIP.ps1
│ ├── Set-OSDComputerNamePrompt.ps1
│ ├── Set-OSDOULocationPrompt.ps1
│ └── ReferencedTaskSequences
│ │ └── Get-ReferencedTaskSequences.ps1
├── Site Administration
│ ├── Compare-IPRangesFirewallRules.ps1
│ └── Get-IPAddressBoundary.ps1
├── Maintenance
│ └── Copy-ConfigMgrBackupFolder.ps1
├── Installation
│ ├── New-CMSourceFolderStructure.ps1
│ ├── Create-CMDeviceCollectionFolders.ps1
│ ├── Test-CMConnection.ps1
│ └── Install-DFSSourceContent.ps1
├── Deployments
│ └── Remove-ApplicationDeployment.ps1
├── WindowsForms-Template.ps1
├── Users
│ ├── Clean-CMPrimaryUserData.ps1
│ ├── Remove-PrimaryDeviceRelationship.ps1
│ └── Get-CMPrimaryUserAssignmentSource.ps1
├── Script-TemplateWMI.ps1
├── Script-TemplateCM.ps1
├── Migration
│ └── Get-Devices.ps1
├── Script-TemplateCMModule.ps1
├── Content
│ ├── Invoke-CMFailedContentRefresh.ps1
│ └── Invoke-CMDeploymentTypeContentUpdate.ps1
├── Package
│ ├── Get-CMDisabledPrograms.ps1
│ └── Remove-PackagesFromList.ps1
├── Queries
│ ├── Import-CMStatusMessageQuery.ps1
│ └── Import-CMQuery.ps1
├── WMI Eventing
│ └── Create-ApplicationApprovalEventing.ps1
└── Collection
│ ├── Update-CMLimitingCollection.ps1
│ └── Remove-DeviceFromCollection.ps1
├── VMware
├── Invoke-ConfigureVMIDEHardDisks.ps1
└── Invoke-ConfigureVMSCSIHardDisks.ps1
├── README.md
├── AzureAD
├── Set-AADUserPasswordExpiresPolicy.ps1
├── New-AADServiceAccount.ps1
└── Remove-AADSynchronizedUsers.ps1
└── MDT
└── Reference Image
├── Invoke-RemoveBuiltinApps.ps1
└── Install-VisualCRedist.ps1
/Intune/placeholder.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/ConfigMgr/OS Deployment/Branding/placeholder.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/ConfigMgr/OS Deployment/Branding/Wallpaper/4K/howto.txt:
--------------------------------------------------------------------------------
1 | Place all 4K wallpapers in this folder.
--------------------------------------------------------------------------------
/VMware/Invoke-ConfigureVMIDEHardDisks.ps1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NickolajA/PowerShell/HEAD/VMware/Invoke-ConfigureVMIDEHardDisks.ps1
--------------------------------------------------------------------------------
/VMware/Invoke-ConfigureVMSCSIHardDisks.ps1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NickolajA/PowerShell/HEAD/VMware/Invoke-ConfigureVMSCSIHardDisks.ps1
--------------------------------------------------------------------------------
/ConfigMgr/Modules/CM2012Module/CM2012_0.1.psd1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NickolajA/PowerShell/HEAD/ConfigMgr/Modules/CM2012Module/CM2012_0.1.psd1
--------------------------------------------------------------------------------
/ConfigMgr/Modules/CM2012Module/CM2012_0.2.psd1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NickolajA/PowerShell/HEAD/ConfigMgr/Modules/CM2012Module/CM2012_0.2.psd1
--------------------------------------------------------------------------------
/ConfigMgr/OS Deployment/Branding/Wallpaper/img0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NickolajA/PowerShell/HEAD/ConfigMgr/OS Deployment/Branding/Wallpaper/img0.jpg
--------------------------------------------------------------------------------
/ConfigMgr/Software Updates/CreateSoftwareUpdateGroup/CreateSoftwareUpdateGroup.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/NickolajA/PowerShell/HEAD/ConfigMgr/Software Updates/CreateSoftwareUpdateGroup/CreateSoftwareUpdateGroup.zip
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PowerShell Repository
2 |
3 | This repository will consist of PowerShell scripts or modules that I've created for the following products:
4 |
5 | - ConfigMgr
6 | - Intune
7 | - AzureAD
8 | - MDT
9 | - VMware
10 |
11 |
--------------------------------------------------------------------------------
/ConfigMgr/OS Deployment/Branding/Wallpaper/Modules/howto.txt:
--------------------------------------------------------------------------------
1 | Download the NTFSSecurity PowerShell module from 'https://ntfssecurity.codeplex.com/' and extract it into this folder.
2 | Do not create a sub-folder, simply just extract the contents of the module.
--------------------------------------------------------------------------------
/ConfigMgr/Client & Devices/Clean-CMClientCache.ps1:
--------------------------------------------------------------------------------
1 | $ResourceMgr = New-Object -ComObject "UIResource.UIResourceMgr"
2 | $CacheInfo = $ResourceMgr.GetCacheInfo()
3 | $CacheInfo.GetCacheElements() | ForEach-Object {
4 | Write-Output "Deleting ContentID:" $_.ContentID
5 | Write-Output "Content location:" $_.Location
6 | Write-Output ""
7 | $CacheInfo.DeleteCacheElement($_.CacheElementID)
8 | }
--------------------------------------------------------------------------------
/ConfigMgr/OS Deployment/Export-TSVariableValues.ps1:
--------------------------------------------------------------------------------
1 | $TSEnvironment = New-Object -ComObject Microsoft.SMS.TSEnvironment
2 | $Variables = $TSEnvironment.GetVariables()
3 | $Variables | ForEach-Object {
4 | Add-Content -Path "$($env:SystemDrive)\Windows\Temp\OSDVariables.log" -Value "############ Variable: $($_) ############"
5 | Add-Content -Path "$($env:SystemDrive)\Windows\Temp\OSDVariables.log" -Value $TSEnvironment.Value("$($_)")
6 | Add-Content -Path "$($env:SystemDrive)\Windows\Temp\OSDVariables.log" -Value "#########################################"
7 | }
--------------------------------------------------------------------------------
/ConfigMgr/Application/Get-MSIFileInformation.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [parameter(Mandatory=$true)]
3 | [IO.FileInfo]$Path,
4 | [parameter(Mandatory=$true)]
5 | [ValidateSet("ProductCode","ProductVersion","ProductName")]
6 | [string]$Property
7 | )
8 | try {
9 | $WindowsInstaller = New-Object -ComObject WindowsInstaller.Installer
10 | $MSIDatabase = $WindowsInstaller.GetType().InvokeMember("OpenDatabase","InvokeMethod",$Null,$WindowsInstaller,@($Path.FullName,0))
11 | $Query = "SELECT Value FROM Property WHERE Property = '$($Property)'"
12 | $View = $MSIDatabase.GetType().InvokeMember("OpenView","InvokeMethod",$null,$MSIDatabase,($Query))
13 | $View.GetType().InvokeMember("Execute", "InvokeMethod", $null, $View, $null)
14 | $Record = $View.GetType().InvokeMember("Fetch","InvokeMethod",$null,$View,$null)
15 | $Value = $Record.GetType().InvokeMember("StringData","GetProperty",$null,$Record,1)
16 | return $Value
17 | }
18 | catch {
19 | Write-Output $_.Exception.Message
20 | }
--------------------------------------------------------------------------------
/ConfigMgr/Tools/GetTSPackageReferenceTool/TSReference.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ContextMenu
4 |
5 |
6 | AdminUI.CollectionProperty.dll
7 | Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources
8 |
9 |
10 |
11 | AdminUI.UIResources.dll
12 | Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
13 |
14 | OSD_TaskSequenceList
15 |
16 |
17 | "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
18 | -windowstyle hidden -executionpolicy bypass -file "C:\Scripts\Get-TSPackageReferences.ps1" -SiteServer "##SUB:__Server##" -TaskSequence "##SUB:Name##"
19 |
20 |
--------------------------------------------------------------------------------
/ConfigMgr/Software Updates/CreateSoftwareUpdateGroup/CreateSoftwareUpdateGroup.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | DefaultHomeTab
4 | ContextMenu
5 |
6 |
7 | AdminUI.CollectionProperty.dll
8 | Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources
9 |
10 |
11 |
12 | AdminUI.UIResources.dll
13 | Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
14 |
15 | SUM_Update
16 |
17 |
18 | "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
19 | -WindowStyle Hidden -ExecutionPolicy ByPass -File #PATH# -SiteServer #SERVER#
20 |
21 |
--------------------------------------------------------------------------------
/ConfigMgr/Tools/GetMaintenanceWindow/MW.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ContextMenu
4 |
5 |
6 | AdminUI.CollectionProperty.dll
7 | Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources
8 |
9 |
10 |
11 | AdminUI.UIResources.dll
12 | Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
13 |
14 | Information
15 |
16 |
17 | "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
18 | -windowstyle hidden -executionpolicy bypass -file "C:\Scripts\Get-MaintenanceWindows.ps1" -SiteServer "##SUB:__Server##" -SiteCode "##SUB:SiteCode##" -ResourceID "##SUB:ResourceID##"
19 |
20 |
--------------------------------------------------------------------------------
/ConfigMgr/Site Administration/Compare-IPRangesFirewallRules.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [parameter(Mandatory=$true)]
3 | $IPRangeOld,
4 | [parameter(Mandatory=$true)]
5 | $IPRangeNew
6 | )
7 | Begin {
8 | $ReferenceObject = $IPRangeOld.Split(",")
9 | $ReferenceObjectCount = [System.Math]::Round(($ReferenceObject | Measure-Object).Count / 2)
10 | $DifferenceObject = $IPRangeNew.Split(",")
11 | $DifferenceObjectCount = [System.Math]::Round(($DifferenceObject | Measure-Object).Count / 2)
12 | if ($ReferenceObjectCount -ge $DifferenceObjectCount) {
13 | $SyncWindow = $ReferenceObjectCount
14 | }
15 | else {
16 | $SyncWindow = $DifferenceObjectCount
17 | }
18 | }
19 | Process {
20 | Compare-Object -ReferenceObject $ReferenceObject -DifferenceObject $DifferenceObject -SyncWindow $SyncWindow | ForEach-Object {
21 | if ($_.SideIndicator -like "=>") {
22 | $Object = New-Object -TypeName PSObject
23 | $Object | Add-Member -MemberType NoteProperty -Name Difference -Value ($_.InputObject)
24 | $Object | Add-Member -MemberType NoteProperty -Name Origin -Value ($_.SideIndicator)
25 | Write-Output $Object
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/ConfigMgr/Maintenance/Copy-ConfigMgrBackupFolder.ps1:
--------------------------------------------------------------------------------
1 | #========================================================================
2 | # Created on: 2013-09-13 09:49
3 | # Created by: Nickolaj Andersen
4 | # Filename: Copy-ConfigMgrBackupFolder.ps1
5 | #========================================================================
6 |
7 | $DailyBackupFolder = "\\fileshare\ContentLibrary\Daily"
8 | $ArchiveFolder = "\\fileshare\ContentLibrary\Archive"
9 | $Date = (Get-Date).ToShortDateString()
10 | $DateKeep = (Get-Date).AddDays(-2).ToShortDateString()
11 | $DailyFolder = "$($ArchiveFolder)\$($Date)"
12 |
13 | if (-not(Test-Path -Path $DailyFolder)) {
14 | New-Item -Type Directory $DailyFolder | Out-Null
15 | }
16 |
17 | if ((Get-ChildItem -Path $DailyBackupFolder).Count -eq 1) {
18 | $BackupFolderPath = Get-ChildItem -Path $DailyBackupFolder | Select-Object -ExpandProperty FullName
19 | Move-Item -Path $BackupFolderPath -Destination $DailyFolder -Force
20 | }
21 |
22 | $ArchiveFolders = Get-ChildItem -Path $ArchiveFolder | Select-Object -ExpandProperty Name
23 | $ArchiveFolders | ForEach-Object {
24 | if ($_ -lt $DateKeep) {
25 | Remove-Item -Path ($ArchiveFolder + "\" + $_) -Recurse -Force | Out-Null
26 | }
27 | }
--------------------------------------------------------------------------------
/ConfigMgr/Tools/DellWarranty/DellWarranty.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | DefaultHomeTab
4 | ContextMenu
5 |
6 |
7 | AdminUI.CollectionProperty.dll
8 | Microsoft.ConfigurationManagement.AdminConsole.CollectionProperty.Properties.Resources.resources
9 |
10 |
11 |
12 | AdminUI.UIResources.dll
13 | Microsoft.ConfigurationManagement.AdminConsole.UIResources.Properties.Resources.resources
14 |
15 | Information
16 |
17 |
18 | "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
19 | -WindowStyle Hidden -ExecutionPolicy ByPass -File "C:\Scripts\Get-DellWarrantyStatus_2.0.ps1" -SiteServer ##SUB:__Server## -DeviceName ##SUB:Name## -ResourceID ##SUB:ResourceID##
20 |
21 |
--------------------------------------------------------------------------------
/ConfigMgr/OS Deployment/Set-CMBootImageEnableCommandLineSupport.ps1:
--------------------------------------------------------------------------------
1 | param(
2 | [parameter(Mandatory=$true)]
3 | $SiteServer,
4 | [parameter(Mandatory=$true)]
5 | $SiteCode,
6 | [parameter(Mandatory=$true)]
7 | $BootImageName,
8 | [parameter(Mandatory=$false)]
9 | [switch]$Commit
10 | )
11 | Begin {
12 | Write-Output "INFO: Querying SMS_BootImagePackage for Boot Images"
13 | $BootImages = Get-WmiObject -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_BootImagePackage -Filter "Name like '%$($BootImageName)%'"
14 | if ($BootImages -ne $null) {
15 | if (($BootImages | Measure-Object).Count -eq 1) {
16 | Write-Output "INFO: Located $(($BootImages | Measure-Object).Count) Boot Image called '$($BootImages.Name)'"
17 | }
18 | else {
19 | Write-Output "INFO: Located $(($BootImages | Measure-Object).Count) Boot Images called:"
20 | foreach ($Boot in $BootImages) {
21 | Write-Output "INFO: '$($Boot.Name)'"
22 | }
23 | }
24 | }
25 | }
26 | Process {
27 | if ($Commit) {
28 | foreach ($BootImage in $BootImages) {
29 | $BootImage = [wmi]"$($BootImage.__PATH)"
30 | $BootImage.EnableLabShell = $true
31 | $BootImage.Put()
32 | }
33 | }
34 | else {
35 | Write-Output "INFO: The Commit switch was not specified, will not edit any found instances"
36 | }
37 | }
38 |
39 |
40 |
--------------------------------------------------------------------------------
/ConfigMgr/Installation/New-CMSourceFolderStructure.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding(SupportsShouldProcess=$true)]
2 | param(
3 | [parameter(Mandatory=$true)]
4 | $DriveLetter,
5 | [parameter(Mandatory=$true)]
6 | $FolderName
7 | )
8 | Begin {
9 | }
10 | Process {
11 | $FolderStructure = @(
12 | "$($DriveLetter)\$($FolderName)",
13 | "$($DriveLetter)\$($FolderName)\Apps",
14 | "$($DriveLetter)\$($FolderName)\Pkgs",
15 | "$($DriveLetter)\$($FolderName)\SUM",
16 | "$($DriveLetter)\$($FolderName)\SUM\ADRs",
17 | "$($DriveLetter)\$($FolderName)\OSD",
18 | "$($DriveLetter)\$($FolderName)\OSD\BootImages",
19 | "$($DriveLetter)\$($FolderName)\OSD\CSettings",
20 | "$($DriveLetter)\$($FolderName)\OSD\DriverSources",
21 | "$($DriveLetter)\$($FolderName)\OSD\DriverPackages",
22 | "$($DriveLetter)\$($FolderName)\OSD\OSImages",
23 | "$($DriveLetter)\$($FolderName)\OSD\MDT",
24 | "$($DriveLetter)\$($FolderName)\OSD\MDT\Settings",
25 | "$($DriveLetter)\$($FolderName)\OSD\MDT\Toolkit"
26 | )
27 | $FolderStructure | ForEach-Object {
28 | try {
29 | if (-not(Test-Path -Path $_ -ErrorAction SilentlyContinue)) {
30 | Write-Output "INFO: Creating folder $($_)"
31 | New-Item -Path $_ -ItemType Directory | Out-Null
32 | }
33 | }
34 | catch {
35 | Write-Error $_.Exception
36 | }
37 | }
38 | }
39 | End {
40 | }
--------------------------------------------------------------------------------
/ConfigMgr/Deployments/Remove-ApplicationDeployment.ps1:
--------------------------------------------------------------------------------
1 | #========================================================================
2 | # Created on: 2013-09-13 16:43
3 | # Created by: Nickolaj Andersen
4 | # Filename: Remove-ApplicationDeployment.ps1
5 | #========================================================================
6 |
7 | param(
8 | [parameter(Mandatory=$true)]
9 | $SiteServer,
10 | [parameter(Mandatory=$true)]
11 | $SiteCode,
12 | [parameter(Mandatory=$true)]
13 | $ApplicationName
14 | )
15 |
16 | if (Get-WmiObject -Namespace "root\sms\site_$($SiteCode)" -Class "SMS_Application" -ComputerName $SiteServer -ErrorAction SilentlyContinue | Where-Object { $_.LocalizedDisplayName -like "$($ApplicationName)"}) {
17 | $Deployment = (Get-WmiObject -Namespace "root\sms\site_$($SiteCode)" -Class "SMS_ApplicationAssignment" -ComputerName $SiteServer | Where-Object { $_.ApplicationName -like "$($ApplicationName)"}).__PATH
18 | $i = 0
19 | if (($Deployment -eq $null) -or ($Deployment -eq "")) {
20 | Write-Warning "No deployments was found for application $($ApplicationName)"
21 | }
22 | else {
23 | $Deployment | ForEach-Object {
24 | $i++
25 | Write-Output ""
26 | Write-Output "Deleting deployment $($i) of $($Deployment.Count): $($_)`n"
27 | Remove-WmiObject -InputObject $_ | Out-Null
28 | Write-Output "Successfully deleted $($i) deployments for $($ApplicationName)`n"
29 | }
30 | }
31 | }
32 | else {
33 | Write-Warning "Application '$($ApplicationName)' was not found"
34 | }
--------------------------------------------------------------------------------
/ConfigMgr/WindowsForms-Template.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding(SupportsShouldProcess=$true)]
2 | param(
3 | [parameter(Mandatory=$true, HelpMessage="Specify the Primary Site server")]
4 | [ValidateNotNullOrEmpty()]
5 | [string]$SiteServer
6 | )
7 | Begin {
8 | # Assemblies
9 | try {
10 | Add-Type -AssemblyName "System.Drawing" -ErrorAction Stop
11 | Add-Type -AssemblyName "System.Windows.Forms" -ErrorAction Stop
12 | }
13 | catch [System.UnauthorizedAccessException] {
14 | Write-Warning -Message "Access denied when attempting to load required assemblies" ; break
15 | }
16 | catch [System.Exception] {
17 | Write-Warning -Message "Unable to load required assemblies. Error message: $($_.Exception.Message). Line: $($_.InvocationInfo.ScriptLineNumber)" ; break
18 | }
19 | }
20 | Process {
21 | function Load-Form {
22 | $Form.Add_Shown({$Form.Activate()})
23 | $Form.ShowDialog() | Out-Null
24 | }
25 |
26 | # Forms
27 | $Form = New-Object System.Windows.Forms.Form
28 | $Form.Size = New-Object System.Drawing.Size(350,100)
29 | $Form.MinimumSize = New-Object System.Drawing.Size(350,100)
30 | $Form.MaximumSize = New-Object System.Drawing.Size(350,100)
31 | $Form.SizeGripStyle = "Hide"
32 | $Form.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($PSHome + "\powershell.exe")
33 | $Form.Text = "Header"
34 | $Form.ControlBox = $true
35 | $Form.TopMost = $true
36 |
37 | # Load Form
38 | Load-Form
39 | }
--------------------------------------------------------------------------------
/ConfigMgr/Software Updates/Set-ADRDeploymentTime.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding()]
2 | param(
3 | [parameter(Mandatory=$true)]
4 | $SiteServer,
5 | [parameter(Mandatory=$true)]
6 | $SiteCode,
7 | [parameter(Mandatory=$true)]
8 | [int]$CreationTimeDays,
9 | [parameter(Mandatory=$true)]
10 | [int]$DeadlineDays,
11 | [parameter(Mandatory=$true)]
12 | [ValidateScript({$_.Length -eq 4})]
13 | $DeadlineHours
14 | )
15 |
16 | $CurrentDate = (Get-Date).AddDays(-$CreationTimeDays).ToShortDateString()
17 | $Deadline = ([System.Management.ManagementDateTimeConverter]::ToDmtfDateTime((Get-Date).AddDays($DeadlineDays))).Split(".").SubString(0,8)[0]
18 | $Time = "$($DeadlineHours)00"
19 |
20 | $ADRClientDeployment = Get-WmiObject -Namespace "root\sms\site_$($SiteCode)" -Class SMS_UpdateGroupAssignment -ComputerName $SiteServer
21 | foreach ($Deployment in $ADRClientDeployment) {
22 | $CreationDate = $Deployment.ConvertToDateTime($Deployment.CreationTime).ToShortDateString()
23 | $DeploymentName = $Deployment.AssignmentName
24 | if ($CreationDate -gt $CurrentDate) {
25 | Write-Output "Deployment to be modified: `n$($DeploymentName)"
26 | try {
27 | $Deployment.EnforcementDeadline = "$($Deadline)$($Time).000000+***"
28 | $Deployment.Put() | Out-Null
29 | if ($?) {
30 | Write-Output "`nSuccessfully modified deployment`n"
31 | }
32 | }
33 | catch {
34 | Write-Output "`nERROR: $($_.Exception.Message)"
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/ConfigMgr/Users/Clean-CMPrimaryUserData.ps1:
--------------------------------------------------------------------------------
1 | # Register Source name
2 | New-EventLog -LogName "Application" -Source "CCM Clean Primary User"
3 |
4 | # Write EventLog that processing is starting
5 | Write-Eventlog -Logname "Application" -Source "CCM Clean Primary User" -EventID 64351 -EntryType Information -Message "Start Processing object(s)."
6 |
7 | try {
8 | # Collect filtered State Messages from CCM_StateMsg
9 | $StateMsgs = Get-WmiObject -Namespace root\ccm\StateMsg -Class CCM_StateMsg -Filter "TopicID like '%Auto%'" -ErrorAction Stop
10 |
11 | # Count objects returned from WMI query
12 | $StateMsgsCount = ($StateMsgs | Measure-Object).Count
13 | Write-Eventlog -Logname "Application" -Source "CCM Clean Primary User" -EventID 64352 -EntryType Information -Message "Found $($StateMsgsCount) Object(s)."
14 |
15 | # Check if there's any object to process
16 | if ($StateMsgs -ne $null) {
17 | # Remove each object
18 | foreach ($StateMsg in $StateMsgs) {
19 | $StateMsg.Get()
20 | $PrimaryUserName = $StateMsg.UserParameters | Select-Object -First 1
21 | Write-Eventlog -Logname "Application" -Source "CCM Clean Primary User" -EventID 64353 -EntryType Information -Message "Removing $($PrimaryUserName) from CCM_StateMsg class."
22 | Remove-WmiObject -InputObject $StateMsg
23 | }
24 | }
25 | }
26 | catch [Exception] {
27 | Write-EventLog -LogName "Application" -Source "CCM Clean Primary User" -EventId 64354 -EntryType Error -Message "Unable to query WMI for objects"
28 | }
--------------------------------------------------------------------------------
/ConfigMgr/Modules/ConfigMgrMigration/ConfigMgrMigration.psd1:
--------------------------------------------------------------------------------
1 | #
2 | # Module manifest for module 'ConfigMgrMigration'
3 | #
4 | # Generated by: Nickolaj Andersen
5 | #
6 | # Generated on: 2015-08-22
7 | #
8 |
9 | @{
10 |
11 | # Script module or binary module file associated with this manifest.
12 | RootModule = 'ConfigMgrMigration'
13 |
14 | # Version number of this module.
15 | ModuleVersion = '1.0'
16 |
17 | # ID used to uniquely identify this module
18 | GUID = 'af5f9455-4422-4eb0-b045-23adcd421364'
19 |
20 | # Author of this module
21 | Author = 'Nickolaj Andersen'
22 |
23 | # Company or vendor of this module
24 | CompanyName = 'Lumagate AB'
25 |
26 | # Copyright statement for this module
27 | Copyright = '(c) 2015 Lumagate AB. All rights reserved.'
28 |
29 | # Description of the functionality provided by this module
30 | Description = 'ConfigMgr Migration Module for Side-by-Side migrations'
31 |
32 | # Minimum version of the Windows PowerShell engine required by this module
33 | PowerShellVersion = '3.0'
34 |
35 | # Assemblies that must be loaded prior to importing this module
36 | # RequiredAssemblies = 'Microsoft.Web.Administration'
37 |
38 | # Functions to export from this module
39 | FunctionsToExport = 'Get-CMMSoftwareUpdate', 'Export-CMMQuery', 'Import-CMMQuery', 'Export-CMMStatusMessageQuery', 'Import-CMMStatusMessageQuery', 'Start-CMMSoftwareUpdateGroupCleanup', 'Get-CMMDisabledProgram', 'Update-CMMContentSourceTool', 'Validate-CMMDeviceMigration', 'Start-CMMSoftwareUpdateCIUniqueIDCleanup'
40 |
41 | # HelpInfo URI of this module
42 | HelpInfoURI = 'http://www.lumagate.com'
43 |
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/ConfigMgr/Tools/Invoke-AndroidAppWrapperTool.ps1:
--------------------------------------------------------------------------------
1 | Begin {
2 | try {
3 | # Load Assemblies
4 | Add-Type -AssemblyName "System.Drawing" -ErrorAction Stop
5 | Add-Type -AssemblyName "System.Windows.Forms" -ErrorAction Stop
6 |
7 | # Import Intune App Wrapping Tool PowerShell module
8 | $ModulePath = Join-Path -Path "$($env:SystemDrive)\Program Files (x86)\Microsoft Intune Mobile Application Management\Android\App Wrapping Tool\" -ChildPath "IntuneAppWrappingTool.psm1"
9 | #Import-Module -Name $ModulePath -ErrorAction Stop
10 | }
11 | catch [System.UnauthorizedAccessException] {
12 | Write-Warning -Message "Access denied" ; break
13 | }
14 | catch [System.Exception] {
15 | Write-Warning -Message $_.Exception.Message ; break
16 | }
17 | }
18 | Process {
19 | function Load-Form {
20 | $Form.Controls.AddRange(@(
21 |
22 | ))
23 | $Form.Add_Shown({$Form.Activate()})
24 | [void]$Form.ShowDialog()
25 | }
26 |
27 | # Forms
28 | $Form = New-Object -TypeName System.Windows.Forms.Form
29 | $Form.Size = New-Object -TypeName System.Drawing.Size(650,350)
30 | $Form.MinimumSize = New-Object -TypeName System.Drawing.Size(650,350)
31 | $Form.MaximumSize = New-Object -TypeName System.Drawing.Size(650,350)
32 | $Form.SizeGripStyle = "Hide"
33 | $Form.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($PSHome + "\powershell.exe")
34 | $Form.Text = "Android App Wrapper Tool"
35 | $Form.ControlBox = $true
36 | $Form.TopMost = $true
37 |
38 | # Load Form
39 | Load-Form
40 | }
--------------------------------------------------------------------------------
/ConfigMgr/Application/Create-CMConsoleApplication.ps1:
--------------------------------------------------------------------------------
1 | # Import ConfigMgr PowerShell module
2 | Import-Module -Name ConfigurationManager
3 |
4 | # Set PSDrive
5 | Set-Location -Path P01:
6 |
7 | # Define Application properties
8 | $ApplicationName = "ConfigMgr 2012 R2 SP1 CU1 Console"
9 | $ApplicationDescription = "Created with PowerShell"
10 | $ApplicationSoftwareVersion = "5.0.8239.1206"
11 | $ApplicationPublisher = "Microsoft"
12 | $ApplicationPath = "\\CM01\Source$\Apps\CM2012R2SP1Console\AdminConsole.msi"
13 | $DPGroupName = "All DPs"
14 |
15 | # Create Applicaton
16 | $ApplicationArguments = @{
17 | Name = $ApplicationName
18 | Description = $ApplicationDescription
19 | Publisher = $ApplicationPublisher
20 | SoftwareVersion = $ApplicationSoftwareVersion
21 | ReleaseDate = (Get-Date)
22 | LocalizedApplicationName = $ApplicationName
23 | }
24 | New-CMApplication @ApplicationArguments
25 |
26 | # Create DeploymentType
27 | $DeploymentTypeArguments = @{
28 | ApplicationName = $ApplicationName
29 | DeploymentTypeName = $ApplicationName
30 | InstallationFileLocation = $ApplicationPath
31 | ForceforUnknownPublisher = $true
32 | MsiInstaller = $true
33 | InstallationBehaviorType = "InstallForSystem"
34 | InstallationProgram = "cscript.exe InstallConfigMgrConsole.vbs"
35 | OnSlowNetworkMode = "DoNothing"
36 | }
37 | Add-CMDeploymentType @DeploymentTypeArguments
38 |
39 | # Distribute content to DPG
40 | $ContentDistributionArguments = @{
41 | ApplicationName = $ApplicationName
42 | DistributionPointGroupName = $DPGroupName
43 | }
44 | Start-CMContentDistribution @ContentDistributionArguments
--------------------------------------------------------------------------------
/ConfigMgr/OS Deployment/Get-TSExecutionStatusForDevice.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding()]
2 | param(
3 | [parameter(Mandatory=$true)]
4 | $SiteServer,
5 | [parameter(Mandatory=$true)]
6 | $SiteCode,
7 | [parameter(Mandatory=$true)]
8 | $ComputerName,
9 | [parameter(Mandatory=$true)]
10 | $PastHours
11 | )
12 |
13 | $TimeFrame = [System.Management.ManagementDateTimeConverter]::ToDmtfDateTime((Get-Date).AddHours(-$PastHours))
14 | $TSSummary = Get-WmiObject -Namespace "root\SMS\site_$($SiteCode)" -Class SMS_StatusMessage -ComputerName $SiteServer -Filter "(Component like 'Task Sequence Engine') AND (MachineName like '$($ComputerName)' AND (MessageID = 11143))" -ErrorAction Stop
15 | $StatusMessageCount = ($TSSummary | Measure-Object).Count
16 | if (($TSSummary -ne $null) -and ($StatusMessageCount -eq 1)) {
17 | foreach ($Object in $TSSummary) {
18 | if (($Object.Time -ge $TimeFrame)) {
19 | $PSObject = New-Object -TypeName PSObject -Property @{
20 | SuccessExecutionTime = [System.Management.ManagementDateTimeconverter]::ToDateTime($Object.Time)
21 | MachineName = $Object.MachineName
22 | }
23 | Write-Output $PSObject
24 | }
25 | }
26 | }
27 | elseif (($TSSummary -ne $null) -and ($StatusMessageCount -ge 2)) {
28 | foreach ($Object in $TSSummary) {
29 | if ($Object.Time -ge $TimeFrame) {
30 | $PSObject = New-Object -TypeName PSObject -Property @{
31 | SuccessExecutionTime = [System.Management.ManagementDateTimeconverter]::ToDateTime($Object.Time)
32 | MachineName = $Object.MachineName
33 | }
34 | Write-Output $PSObject
35 | }
36 | }
37 | }
38 | else {
39 | Write-Output "No matches found"
40 | }
--------------------------------------------------------------------------------
/ConfigMgr/Script-TemplateWMI.ps1:
--------------------------------------------------------------------------------
1 | <#
2 | .SYNOPSIS
3 |
4 | .DESCRIPTION
5 |
6 | .PARAMETER SiteServer
7 | Site server name with SMS Provider installed
8 | .PARAMETER ShowProgress
9 | Show a progressbar displaying the current operation
10 | .EXAMPLE
11 |
12 | .NOTES
13 | Script name: