In this post:
- How Do I Paste Code into the Windows PowerShell Console?
- Automation with Windows PowerShell
- How Can I Create an Automated Lockdown for Windows 7 by Using Windows PowerShell?
- How Can I Filter Search Results in the Script Repository?
- How Can I Delete Profiles in Windows Vista?
Hey, Scripting Guy! How do I copy an example from a site and then paste it into Windows PowerShell? Ctrl+C followed by Ctrl+V does not work.
If you are talking about pasting code into the Windows PowerShell console, you cannot use Ctrl+C followed by Ctrl+V. Copy to the clipboard in the Windows PowerShell console by highlighting the code with the mouse and pressing Enter. Paste from the clipboard by right-clicking inside the Windows PowerShell console.
You can also use the menu. For example, in the upper left of the Windows PowerShell console, click the Windows PowerShell icon, click Edit, and then click Paste.
Hey, Scripting Guy! Maybe this is a little too advanced, but I need help in doing some UI automation with Windows PowerShell.I have an older program that I need to do things with three times a day. Same thing every day. There are two .exe files that I need to run, EXEA and EXEB. Here is what I am trying to automate.
8am – Exit EXEB, by automating File, Exit.
Click menu, then taskA
Click Menu, then TaskB
Noon – Click menu, then TaskA
Click menu, then TaskB
5pm – Exit EXEA, by automating File,Exit
Login (as program requires, not worried about password security).
Can you help?
Check out the WASP project on CodePlex. It might be just what you need. WASP was developed by the Windows PowerShell community, and seems to be pretty cool.
Hey, Scripting Guy! I am trying to create an automated lockdown for Windows 7 using Windows PowerShell, but I am stuck on a couple parts. I need to be able to change the entries in Local Computer PolicyComputer ConfigurationWindows SettingsSecurity Settings, but I am not having any luck finding the information to do so. Normally, I would use a domain controller to lock these down, but there is no domain controller on this network. I am of course able to do so with secpol.msc, but it would make the life of my administrators easier if I could script it.
Many Group Policy settings are an abstraction of settings that are available via the registry. There is a Group Policy settings reference for Windows Server 2008 R2 and for Windows 7 available on the Microsoft Download Center. The same link also has downloadable documentation that covers Windows 2003 and Windows Vista. There is an additional download that details Windows Internet Explorer 8 Group Policy Settings that is also available on the Microsoft Download Center.
Using Windows PowerShell, it is trivial to make changes to the registry. This collection of Hey, Scripting Guy! posts illustrates various techniques for working with the registry. Registry manipulation was an event in the last two Scripting Games, so there are some Scripting Games event articles in the collection. These articles also provide essential information about working with the registry via Windows PowerShell and should not be missed.
Hey, Scripting Guy! In the Script Repository, you should allow sorting by script type, so if i am looking for Windows PowerShell in community scripts I just sort by Windows PowerShell. Do that for all lists would be great.
P.S. Scripting Guys ROCK!!!! You have changed my entire way of doing things and made me climb the corporate ladder much faster. Thanks for the POWERSHELL!!!!!!!
That sorting capability is already available on the Script Repository. In the Script Repository on the lower left side under the list of script categories, there is the Affiliation section. If you click Microsoft, you are shown the scripts submitted by Microsoft team members. If you click Community, you are given the scripts submitted by the scripting community at large.
Under the Affiliation section is the Script Language section. If you click Windows PowerShell, you are shown only the Windows PowerShell scripts. If you click VBScript, you are given only the VBScripts. You can further reduce by platform such that if you click Windows 7, you are given only Windows 7 scripts. Keep in mind that if you search by Verified Platform, you may miss some scripts because not all scripts are marked with all the platforms under which they will run. Therefore, if your filter included Microsoft, Windows PowerShell, and Windows 7, only scripts tagged with all three of those tags would be included in your results.
Further, if you now type WSUS in the search box, you would retrieve only WSUS scripts from Microsoft that are written in Windows PowerShell run on Windows 7. This is shown in the following image.
As you can see, the combination of filter and search is additive—and quite powerful (if not entirely intuitive). I hope you enjoy our Script Repository. We now have more than 5,000 scripts in the repository, and the search/filter capability is definitely a welcome addition.
One important note: If you do not “zero out” your filters, they will be applied to your searches until you do remove them. It is something I keep forgetting to do from time to time.
Hey, Scripting Guy! I have tried to remedy this problem, but so far no luck. We are using Windows Vista in our labs and they get cached profiles.
With Windows XP, I could write a simple script and use delprof, but delprof does not work with Windows Vista Ultimate. I also tried remprof, but it appears that Windows Vista causes this utility to work incorrectly.
I also tried the Group Policy suggestion, but apparently it does not work correctly and the fix Microsoft suggests to fix the Group Policy object problem seems to come in contention with Windows Vista Ultimate. I thought that perhaps either Windows PowerShell or VBScript could solve the problem. I have Windows PowerShell 1.0 on all the systems with this issue.
The user profiles are created and they are allowed to stay on the system for no longer than two days (these are not roaming profiles). Any help would be appreciated.
The reason that delprof was removed from Vista is that the Windows Profile is referenced in several locations, and it gets tied in with many applications. There were "issues" with removing the profile with delprof, and because it was rather complicated, delprof was removed. The "proper" way to remove a profile is to use Group Policy. If you are having problems using Group Policy to remove cached profiles because it does not work properly, that is a bug, and you should contact Microsoft Support and get them to address the situation to your satisfaction. There should be a workaround at least because Windows Vista is used in millions of computers in schools all over the world, and I cannot believe you are the only school system that needs to remove cached profiles because of disk space issues and other concerns.
As far as deleting the physical profile on the disk, there are rights issues that must be dealt with. Here is a Hey, Scripting Guy! post in which I talk about removing the profile that is stored on a remote file server. You will have the exact situation on a local box.
You also have the registry that maintains profile listing:
But beyond that, things begin to get murky.
Well, this concludes another edition of Quick-Hits Friday. Join us tomorrow for Weekend Scripter as we create a Group Policy setting to deploy the performance tracing script developed in last week’s Weekend Scripter post.
We would love for you to follow us on Twitter and Facebook. If you have any questions, send email to us at firstname.lastname@example.org, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson and Craig Liebendorfer, Scripting Guys