Powershell thinking

Discussion in 'Networks' started by zxspectrum, Mar 16, 2016.

  1. zxspectrum

    zxspectrum Terabyte Poster Forum Leader Gold Member


    I am going to try and write a Powershell script to delete user profiles from PCs as well as deleting the Reg Key of a particular user.

    We have head temp profile issues with a user today, he had used 10 pcs in total, which meant checking each individual pc and renaming the profile, then deleting that users Reg Key, where we could we used AB tutor do do it remotely, Or using the run command and regedit, we tried to connect to network registry however we did encounter issues with that.

    So I will need a structured approach to do this which is where I would like some input/pointers if possible. Its not going to be in powershell language, just English so I have a clearstructure in my head.

    This is what I want the script to do

    Scan the Domain for user Joe Bloggs, then rename the profile of that user to Joebloggs1. After that I would like it to delete the regkey of the user that has been deleted.

    Does that make sense from that approach of do you think I need to be thinking of something that needs adding, or do you think the approach is wrong?

    Cheers for any input

    Certifications: BSc computing and information systems
    WIP: 70-680
  2. dales

    dales Terabyte Poster

    I would be inclined to take the easy route and use delprof2 as part of a scheduled task with a REG DELETE dos command at the end. Powershell is great and I use it a lot but sometimes its just easier to use the old methods! :)
    Certifications: vExpert 2014+2015+2016,VCP-DT,CCE-V, CCE-AD, CCP-AD, CCEE, CCAA XenApp, CCA Netscaler, XenApp 6.5, XenDesktop 5 & Xenserver 6,VCP3+5,VTSP,MCSA MCDST MCP A+ ITIL F
    WIP: Nothing
  3. Juelz

    Juelz Gigabyte Poster

    Sorry Ed, I don't want to hijack your thread or pull attention away from your original question, but PowerShell scripting is something I am very confused about even after research.. is PowerShell scripting done with the PowerShell ISE application or notepad? I saw a method of importing a script via creating it in Notepad first but then I found that this PowerShell ISE is apparently some script building software? just wondering what method you use? I'm pretty much a novice when it comes to PowerShell, used it abit at work these past few weeks, but nothing major, it would be brilliant if I could create entire scripts instead of manually typing/pasting commands in one at a time.
  4. zxspectrum

    zxspectrum Terabyte Poster Forum Leader Gold Member

    By all means I am no power shell god, I am probably in the same boat as you on this post I was querying whether my thought process of coming up with the script was right or along the right lines.

    There is a lad in work who does this for fun, I know what PS can do, which is why I am pushing and pushing until something clicks.

    I use the console but I am going to start using the ISe as when you type you get a dropdown box of available commands which if related to what you want to do is in that list can be useful. Joining together one command to another is where the pipeline comes in, the easiest example i can give you of that is

    Get-help get-aduser -detailed | more When you pipe it to more, instead of the page scrolling at a million miles per hour it will stop at each page stop until you press the space bar. You can also use that pipeline to send that info to a text file or use .ogv which is out grid view, basically it will put this in a table for you.

    One of the other things I struggle with is when i have an issue is what does that actual bit belong too which is another learning curve in itself, I mean there is WMI class CIM, and more to know for other aspects. I got to the point of understanding positional parameters and how you can and cant mix some of them depending on where they are. There is also using variables which I can understand but then putting them into practice is a different kettle of fish.

    Seeing as were in the same boat why dont we try and work on some ideas/issues, that way we may both benefit?

    Using this approach for me I think is going to be awkward as you cant say when a profile is going to corrupt and on how many PCs you will need to rename the profile and also when you have made the tool, yeah it may take a day or so to make and get working correctly, but overall you would get the investment in time back in my opinion. Imagine you scan the domain for that user, it gives you a list of every PC he has logged onto, even the ones he has forgotten about (we are talking about teachers here) then it renames that profile and deletes the reg key, all that done in a say 20 seconds, or however long it takes. I hope that makes sense


    Certifications: BSc computing and information systems
    WIP: 70-680

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.