Automate Deleting Old Local Profiles
[PowerShell] Automate Deleting Old Local Profiles from usefulscripts Sent from my iPad
Powershell, ConfigMgr, Windows Client, Windows server…
[PowerShell] Automate Deleting Old Local Profiles from usefulscripts Sent from my iPad
[PowerShell] Getting Bitlocker and LAPS summary report with PowerShell from usefulscripts Sent from my iPad
[PowerShell] Testimo – PowerShell module for Active Directory Health Checks from usefulscripts Sent from my iPad
[PowerShell] PowerShell Modules I’ve worked on in 2019 from usefulscripts Sent from my iPad
[PowerShell] Four commands to help you track down insecure LDAP Bindings before March 2020 from usefulscripts Sent from my iPad
[PowerShell] Visually display Active Directory Nested Group Membership using PowerShell from usefulscripts Sent from my iPad
This function compare what the Distribution Point has in WMI againt ContentLib
1 2 3 4 5 6 7 8 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 |
<# .Synopsis Compare WMI with ContentLIB locally on DP .DESCRIPTION .EXAMPLE .EXAMPLE #> Function Check-PackageWMIvsLIB { $WMIPkgList = Get-WmiObject -Namespace Root\SCCMDP -Class SMS_PackagesInContLib | Select -ExpandProperty PackageID | Sort-Object $ContentLib = (Get-ItemProperty HKLM:SOFTWARE\Microsoft\SMS\DP).ContentLibraryPath $PkgLibPath = ($ContentLib) + ‘\PkgLib’ $PkgLibList = (Get-ChildItem $PkgLibPath | Select -ExpandProperty Name | Sort-Object) $PkgLibList = ($PKgLibList | ForEach-Object {$_.replace(‘.INI’,”")}) $PksinWMIButNotContentLib = Compare-Object -ReferenceObject $WMIPkgList -DifferenceObject $PKgLibList -PassThru | Where-Object { $_.SideIndicator -eq "<=" } $PksinContentLibButNotWMI = Compare-Object -ReferenceObject $WMIPkgList -DifferenceObject $PKgLibList -PassThru | Where-Object { $_.SideIndicator -eq "=>" } write-host write-host Write-Host Items in WMI but not the Content Library -ForegroundColor Green Write-Host ======================================== $PksinWMIButNotContentLib Write-Host Items in Content Library but not WMI -ForegroundColor Green Write-Host ==================================== $PksinContentLibButNotWMI } |
If you want to remove WMI entry that not are in lib
1 |
Get-WMIObject -ComputerName "DPNAME" -Namespace "root\sccmdp" -Query ("Select * from SMS_PackagesInContLib where PackageID = 'PACKAGEID'") | Remove-WmiObject |
Of if you want to remove from ContentLIB
1 2 |
##Delete .ini´s in PkgLib not in WMI Remove-Item -Path "$PkgLibPath\PackageID.INI" -Confirm |
To be used at own…
Read more
www.osdsune.com/home/blog/2019/splash-screen-driver-bios-update
I got a question from the support at a customer how they could add multiple users to multiple groups without user the mmc “users and computers”, this is my quick solution…
1 2 3 4 5 6 7 8 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 |
<# .Synopsis Combine two txt-files to one csv-file to import multi-user to multi-groups in AD .DESCRIPTION This script can be used to import x-numbers of users to x-numbers of ad-groups .EXAMPLE The script is based on three files... - users.txt - a txt-file with users samaccountname - groups.txt - a txt-file with the groups which the users should be member of .EXAMPLE Another example of how to use this workflow .NOTES ************************************************************** Created: 2019-05-08 Version: 1.0 Disclaimer: This script is provided "AS IS" with no warranties Author - Christian Damberg Twitter: @DambergC Blog : https://www.damberg.org ************************************************************** #> #step one - read users.txt file $users = get-content .\users.txt -Encoding UTF8 #step two - this loop will run for all users in txt-file "users.txt" foreach ($user in $users) { #step three - this loop run all groups in "groups.txt" for each user $rk1_group = Get-Content .\groups.txt -Encoding UTF8 foreach ($group in $groups) { #step four - merge both txt-files to "result.txt" "$($user);$group" | Out-File .\result.txt -Append utf8 } } #Step five - import the txt-file "result.txt" and export it to a csv-file named "user_group.csv" import-csv .\result.txt -Delimiter ";" -Header user,group | export-csv .\user_group.csv -NoClobber -Encoding UTF8 #Step six - Read csv-file och run a loop with add-adgroupmember to add each user to each group. #jobbet att lägga till, läs in csv och kör en lopp på hela filen import-csv .\user_group.csv | ForEach-Object {Add-ADGroupMember -Identity $_.group -Members $_.user} #Done |
If you have a folder-structure in ConfigMgr and you need to remove the folders (if they are empty) and you tried to right-click and select remove…you noticed that it takes….looooong time to remove…. The following script removes all folders under…
Read more