Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell script to delete VHD files on Windows LAN clients

Posted on 2011-03-18
4
Medium Priority
?
935 Views
Last Modified: 2012-05-11
Hi

I'd like to experiment with Powershell so here goes:

How would I execute a command on a server to remove VHD (Virtual Hard Disk) files from the F:\ drive on a Windows client called PC01?

Server is 2003 R2 and client is XP SP3

Thanks

Phil

0
Comment
Question by:philanderson888
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 13

Accepted Solution

by:
soostibi earned 200 total points
ID: 35164543
Do you have PowerShell v2 installed and PowerShell remoting enabled?
If yes, you can do this

Invoke-Command -ComputerName PC01 -ScriptBlock {Get-ChildItem -Path f:\ -Recurse -Filter *.vhd | Remove-Item }

If not, then if admin share is accessible you can do this:

Get-ChildItem -Path \\PC01\f$ -Recurse -Filter *.vhd | Remove-Item
0
 

Author Comment

by:philanderson888
ID: 35175412
Hi

I have neither installed - I think I will try this from a Windows 7 virtual machine which I have installed on the network and see if I can make this happen.  Hopefully I will get back to you Mon or Tues at the latest as it's a work machine.

Regards

Phil
0
 

Author Comment

by:philanderson888
ID: 35209820
Hi

Thank you for this - it was simple and it worked fine from a 2003 R2 server with Powershell v1 installed.

Many thanks for your help.

Philip

0
 

Author Closing Comment

by:philanderson888
ID: 35209835
Thanks very much for your help - I may be back for more!
0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question