Jump to content

ish

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by ish

  1. ok, i got the code | Out-File 'C:\results.log' which i have put at the end of the script. it creates the log file, but the file is empty. any ideas? thanks again.
  2. HI Jaminben, Brilliant, worked perfectly as a .ps1 script! Any chance, you can help with me one other thing? Is there a way to get a log file or something that shows whats been deleted etc...... Thanks again, Much appreciated!
  3. ok so i have updated to version 3. the first code ran ok, without any errors. when running the second code i get the following: Sam Account Name: maryam Home Directory: \\Svr-muloom\Data$\Students\blue\maryam Profile Path: \\Svr-muloom\Profiles\Students\blue\maryam Press any key to Close... Exception calling "ReadKey" with "1" argument(s): "The method or operation is not implemented." At line:15 char:1 + $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: ( [], MethodInvocationException + FullyQualifiedErrorId : NotImplementedException this only happens when executing via ise. when executing via a .ps1 script it runs without errors? any ideas? - - - Updated - - - ok so i have updated to version 3. the first code ran ok, without any errors. when running the second code i get the following: Sam Account Name: maryam Home Directory: \\Svr-muloom\Data$\Students\blue\maryam Profile Path: \\Svr-muloom\Profiles\Students\blue\maryam Press any key to Close... Exception calling "ReadKey" with "1" argument(s): "The method or operation is not implemented." At line:15 char:1 + $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: ( [], MethodInvocationException + FullyQualifiedErrorId : NotImplementedException this only happens when executing via ise. when executing via a .ps1 script it runs without errors? any ideas?
  4. version 2? Major Minor Build Revision ----- ----- ----- -------- 2 0 -1 -1
  5. this is what is returned: Home Directory: \\Svr\Data$\Students\blue\maryam Profile Path: \\Svr\Profile\Students\blue\maryam SamAccountName: maryam Press any key to continue... Exception calling "ReadKey" with "1" argument(s): "The method or operation is not implemented." At C:\Users\Administrator\Desktop\delteuserprofilehd.ps1:39 char:28 + $x = $host.UI.RawUI.ReadKey <<<< ("NoEcho,IncludeKeyDown") + CategoryInfo : NotSpecified: ( [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
  6. Hi, here is the code: ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- $users = Get-ADUser -Filter "*" -SearchBase "OU=DELETE,DC=markaz-uloom,DC=ac,DC=uk" -Properties samaccountname, HomeDirectory, profilepath #The user who will take ownership $objUser = New-Object System.Security.Principal.NTAccount("markaz-uloom", "Administrator") $users | ForEach-Object { #Get home directory object $objHomeDirectory = Get-Acl $_.HomeDirectory #Set home directory object ownership to new user $objHomeDirectory.SetOwner($objUser) #delete home directory from server remove-item $_.HomeDirectory -recurse -force Write-Host 'Home Directory: '$_.HomeDirectory #Get profile path object $objProfilePath = Get-Acl $_.profilepath #Set profile path object ownership to new user $objProfilePath.SetOwner($objUser) #delete profile folder from server, delete line if not needed remove-item $_.profilepath -recurse -force Write-Host 'Profile Path: '$_.profilepath `n #delete user account from AD #Remove-ADUser -Identity $_.samaccountname -Confirm:$false #Write-Host 'SamAccountName: '$_.samaccountname } Write-Host "Press any key to continue..." $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") ------------------------------------------------------------------------------------------ I have checked 'Home Directory' and 'Profile Path' both exist.
  7. Hi jaminben, im getting the following error when running the script, can you help/advise? Remove-Item : Cannot bind argument to parameter 'Path' because it is null. At C:\Users\Administrator\Desktop\Untitled4.ps1:10 char:16 + Remove-Item <<<< $user.HomeDirectory + CategoryInfo : InvalidData: ( [Remove-Item], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.RemoveItemCommand your help/advice would be much appreciated thanks ish
×
×
  • Create New...