Copy Group Membership From One User To Another

I couldn’t find an easy quick way to do this so I took an old powershell script I found and modified it to work in Windows 2008 R2 and later environments.

   1: import-module ActiveDirectory
   2: cls 
   3: write-output "This script adds the destination user to all the Groups which the source user is memberof." 
   4: write-output " " 
   5: write-output " " 
   6: $SName = Read-Host "Please Enter the alias name of the source user " 
   7: $DName = Read-Host "Please Enter the alias name of the Destination user " 
   8:  
   9: $K = Get-ADUser -Identity $SName -Properties memberOf
  10: foreach($group in $K.memberof)  
  11: {  
  12: Add-ADGroupMember -Identity $group -Member $DName 
  13: write-output $group 
  14: }  
  15:  

Advertisements

Deleting old Windows Server Backup files

Amazingly, if you are using Windows Server Backup, you have no way to delete old backup files.  The service is supposed to simply grow your backup data until your drive is full, and then it should start cleaning up the old backups, but that isn’t ideal.

I found that I was able to delete the oldest backup by using the command:

DiskShadow.exe

followed by

delete shadows oldest f:

Where f: is the drive that is used for backups.  There is no way to tell it to keepLatest 100 like you can if you were just deleting the system state, but you can put a bunch of delete commands into a text file and point diskshadow at it.