Solved

Powershell script to delete VHD files on Windows LAN clients

Posted on 2011-03-18
4
906 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
  • 3
4 Comments
 
LVL 13

Accepted Solution

by:
soostibi earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks very much for your help - I may be back for more!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now