Script to look up user's SID and then delete entry from registry \ProfileList

I need to be able to run a script VB or PowerShell (PS preferred) to look up a AD user accounts SID, search for that SID in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList and remove that entry.
Is this possible? I have the easy part of the script written, it looks up the SID and stores it but the search of the registry is what I need help with:
Import-Module ActiveDirectory
$UserName = Read-Host "What is the User Name?"
$UserNameSID = Get-ADUser -Identity "$UserName" | Format-List *SID*

Hi,
Yes, that's possible. Here's a starter:
$sid = (Get-ADUser -Identity (Read-Host 'Enter the username')).SID.Value
If (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid") {
Write-Output "Found $sid"
Remove-Item "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid" -Recurse -WhatIf
Links:
http://ss64.com/ps/test-path.html
http://ss64.com/ps/remove-item.html
Don't retire TechNet! -
(Don't give up yet - 13,085+ strong and growing)

Similar Messages

  • If I delete my songs from my "Downloads" folder, have them in my "Trash" and then delete them from my "Trash", will I still be able to play the songs on my iTunes or will they be deleted on my iTunes as well?

    I want to clear some space on my Mac since it is filling up and I don't have much room left on it. I want to delete all my songs from my "Downloads" folder and then delete them from my "Trash" to free up space however, I'm worried that if I do this then iTunes will not play any of the songs I deleted.
    Will I still be able to play my songs on iTunes even if they are not in my "Downloads" or "Trash" folders?
    Thank you.

    All tracks in iTunes (if you use default settings) should be in various artist and album folders in the main media folder in the iTunes folder. You can right click a track to reveal its location in Finder.  If there's a copy there then it doesn't really matter what you do with other copies.
    I have never downloaded from iTunes but I thought it placed files directly in the correct locations, or is this some other downloads folder to which you are referring?
    Normally if you download a file from another source and add it to iTunes by dragging it there, or using the Add To menu item, it places a copy of the file in iTunes.  You can discard the original, but if you're concerned you can check which copy iTunes is actually using as above.

  • Is it possible to save an iPhone back up and access the files later if needed?  I have a string of text sms and iMessages that I would like to save and then delete them from my phone.  Is this possible?

    I have a string of text sms and iMessages that I would like to save and then delete them from my phone, but gain access to them later if I need them.  I prefer to have the string with the date/time stamp vs copying and pasting into a doc or text file.  Is this possible?

    Not unless you buy an app that accesses data from an iTunes backup.  Check in the app store.

  • How do I archive emails in mail and then delete them from my inbox?

    I need to archive a bunch of emails for a project, and I know that if I put them in a mailbox and then delete them from my inbox, they're gone. So, what's the most efficient way to save 100s of emails that will eventually need to be filed within a project file?

    // Sample code
    List resList = new Vector();
    MyObject obj = null;
    while(rs.next()) {
        obj.setXXX(rs.getXXX(i));  // Get from the resultset and set to the object
        resList.add(obj);
    // At the end of the loop, you have a Vector of objects holding data.What do you mean by returning Strings separately?

  • I want to dump my photos from my phone onto my pc automatically, and then delete them from my phone. How do I do this?

    My wife and I both have an iphone 4s. We have been taking photos, and now the space on our phones is maxed out. Is there a way for me to automatically dump the photos onto my computer, and delete photos on my phone so that I hog up the space with photos? It seems like this shouldn't be complicated, but for some reason, I can't figure out how to copy the photos to my pc, and then delete them from my phone.

    Connect the phone to your computer and open whatever image capture application you have on the computer. An application you use to transfer photos from a camera to your PC should work with the iPhone. The computer will recognize the phone as a camera and allow you to copy photos to the computer, you can then keep or delete the photos from the iPhone.

  • Can I save my photos from my iPhone to iCloud/iTunes, and then delete them from my iPhone to  free up space on my iPhone?I would  still like to keep them somewhere where they can  be accessed.

    Can I save my photos from my iPhone to iCloud/iTunes, and then delete them from my iPhone to  free up space on my iPhone?I would  still like to keep them somewhere where they can  be accessed.

    One option is to turn on iCloud Photo Library on the phone and go to Settings > iCloud > Photos and turn on "Optimize iPhone Storage." Then you don't delete the photo from the phone but it does occupy significantly less space. More information in iCloud Photo Library FAQ - Apple Support

  • I backed up a video to icloud and then deleted it from my iPhone but have recently backed up again - will my video still be in icloud?

    I backed up my iPhone to the Cloud a few weeks ago and then deleted a video from my iPhone.  I have since backed up my iPhone again....will my video still be in the iCloud? Does the iCloud when restoring, overwrite existing data on my phone?

    If the latest backup does not include the video, then it won't be restored if you restore from that backup.  Technically, there should be around 3 backups maintained in icloud, but many users find that they have one one choice to make (the latest backup) when they perform a restore from icloud. 
    Like photos, video should always be synced to a computer for archiving.  If you've done that, then you should be able to find it on your computer.

  • I received a "junk" email that I attempted to dispose of by sending it to "trash" and then deleting it from "trash". At that point, instead of deleting, it simply rotates back into "junk"--and over and over. How do I delete this unwanted email?

    I received a  "junk" email and attempted to dispose of it by sending it to "trash" and the deleting it from the trash file (the way I always do). This particular spam, however, instead simply rotates back into the "junk" file-- ad infinatum. How do I eliminate tis unwanted pest?

    Try logging on to your email via the web browser (assuming the email account is gmail, yahoo, etc) and deleting the email from there. It could just be that the email program on the iPad is not properly synching with the web server so the email keeps re-downloading.

  • When using a NAS with iTunes, will iTunes ask if a file should be deleted and then delete it from the NAS?

    I had some bad luck moving to a NAS earlier this year.  I'm trying again now after getting a new hard drive.
    One thing I encountered previously was that it seemed like if I deleted say a podcast or TV show manually that I had watched, I did not get the usual confirmation asking if I wished to delete the file.  More importantly, the file did not seem to delete from the NAS.  I had to go through twice the work to remove it from itunes and then again from the NAS.
    Is that how it is supposed to work if the Itunes media is on a NAS?  Not sure if it was some sort of issue with my previous problems or if that is how it works with itunes and a NAS device?
    Thanks.

    Hey elenaaa21,
    It all depends on what your setup is. So if you have upgraded to iCloud Photo Library, then any changes that are made will be reflected on all devices that have that turned on. You delete a photo on your iPhone, then on iCloud.com you will not see it because it has been deleted. If you are not using iCloud Photo Library, then you will need to delete the photo on all devices to where it shows up. Keep in mind that if this was done very quickly, then it may not have been uploaded to your My Photo Stream as you need to make sure that you are on Wi-Fi and the Camera app be completely closed out. Take a look at the article below for more details and let me know if this clears this up or need further assistance. 
    iCloud Photo Library FAQ
    https://support.apple.com/en-us/HT204264
    My Photo Stream FAQ
    https://support.apple.com/en-us/HT201317
    Take care,
    -Norm G. 

  • How do I store photos on an external hard drive and then delete them from my MacBook hard drive

    I am sure this info is on the support site.  But I can't seem to find it.
    I want to move photos and movies (I'm using iphoto '11, 9.1.3) from my Mac Book hard drive to an external hard drive.
    What are the steps to take to move the photos and movies, and then safely remove them from the MacBook Pro hard drive?
    As an aside, are there any suggestions on external hard drives that work better with Mac (brands, size, Firewire vs USB, etc).
    Nothing sophisticated.  They're family photos, so they are important to me.
    Thanks
    AS

    Moving the iPhoto library is safe and simple - quit iPhoto and drag the iPhoto library intact as a single entity to the external drive - depress the option key and launch iPhoto using the "select library" option to point to the new location on the external drive - fully test it and then trash the old library on the internal drive (test one more time prior to emptying the trash)
    And be sure that the External drive is formatted Mac OS extended (journaled) (iPhoto does not work with drives with other formats) and that it is always available prior to launching iPhoto
    And backup soon and often - having your iPhoto library on an external drive is not a backup and if you are using Time Machine you need to check and be sure that TM is backing up your external drive
    The faster the connection the better,- Firewire or USB II would be the best
    THere are many good ones - I like Other World Computing products or Apple products
    LN

  • HT201317 How do you save photos from photo stream to a Mac and then delete them from iPad?

    I am trying to transfer photos taken from my iPad (where they were taken) and want them saved on my Mac using the icloud and photo stream where the photos now reside.  If I saved them as events on the MAC can they now be deleted from the photo stream?

    Yes.  Set up iPhoto's Photo Stream preferences like this:
    The photos get imported into an Event automatically.  Always confirm that the photos have been safely imported before deleting off your iPad.  Sometimes importing takes a while and you don't wan't to jump the gun on the iPad.
    OT

  • My goal is to backup my pictures and movies and then delete them from my computer to open up more space. What's the best way to do this?

    Let's say I let time machine backup my computer, then I delete most of my pictures (that are now backed up) to make room on my laptop's hard drive. The next time Time Machine backs up my computer will it overwrite the old backup with what it currently sees on my computer? Will it loose all of those pictures, because they're no longer on my laptop?

    ardenm58 wrote:
    Will it loose all of those pictures, because they're no longer on my laptop?
    Yes eventually or sooner by large changes to your boot drive.
    Read
    Most commonly used backup methods

  • Is it possible to make a playlist and then delete those songs from the Music library and only keep them in the Playlist?file

    Is it possible to make a playlist of particular material and then delete them from the Music list and just keep them in the play list?
    than you. first time user/.

    I see you've found your answer here.
    tt2

  • If I purchase an app/game on my desktop iTunes, and then delete it

    and then delete it from my phone later, can I re-download it (for free of course) on my iPhone's iTunes store???? Or will it charge me again?
    Because I know you're free to re-download apps you've already purchased on desktop iTunes, I just want to make sure mobile iTunes is the SAME protocol
    Thank you so much

    It will be a free re-download.

  • Move Users Favorites Folder in Roaming Profile and then Delete?

    Hello,
    My current scenario is as follows for user accounts:
    \\90.244.233.10\userprofile$\User-16 (this is their profile path)
    \\90.244.233.10\userprofile$\User-16\Favorites (this is their favorites folder)
    I need to take the above favorites folder and move it to their userhome$ folder found here:
    \\90.244.233.10\userhome$\%username%\Favorites (these folders already exist) 
    Then delete their complete userprofile$ folder.
    How can I achieve this using powershell? I think the tricky part for me is going through each folder in userprofile$ and looking for a \Favorites folder and then matching that userprofile$ foldername to %username% since they're the same.
    Thank you.

    This worked:
    gc users.txt | % {
    $user = "$_"
    if (Test-Path -Path "\\90.244.233.10\userprofile$\$user\Favorites")
    copy-item -path \\90.244.233.10\userprofile$\$user\Favorites -destination \\90.244.233.10\userhome$\$user\
    remove-item -path \\90.244.233.10\userprofile$\$user -recurse

Maybe you are looking for

  • WD External HD not recognised on Mac Mavericks OSX

    Can anyone help me how to resolve my issue on WD external hd not recognized on mac's finder and disk utility?

  • N91 USB Device Not Recognised

    Can anybody please help. I purchased the N91 phone 6 weeks ago and I still have not been able to get it connected to my PC via cable. I am using the CA-42 Cable supplied with the phone by Nokia. My Operating System in Windows XP Home Edition - Servic

  • Wild card search and multiselection in dashboard prompt????

    Hi all: Actually, I want to make dashboard prompt that filters the customer code, user can select more than one code at a time. But there is one more requiremnet that is, If user wants to find customer code in report than it just write the code or pa

  • Acrobat 5 with Wondows 8.1

    I have been using Acrobat 5 for years,  but my new PC is Windows 8.1 I tried to load it but got a message advising that there may be compatibility issues,   but I can't find any definitive advice about this. I only use Acrobat 5 for creating and addi

  • BT Aqua phone

    Hi - my BT Aqua handset has suddenly gone wrong - instead of the usual display there is only strange symbols and numbers.  There is a dialling tone and you are able to ring out.  I have tried new batteries but has no effect.  Does anyone have any ide