Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

can't delete a file

$
0
0

This code works when I run it against my local computer.

 

 

$packageID = Read-Host 

   remove-item c:\temp\tmp\remove\$packageID.* 

   remove-item c:\temp\tmp\remove2\$packageID.*

 

The file $packageID.* was removed from each folder.

 

But when I try to run this against remote computers it does not work.  I get no error but no files get deleted on the remote machines.

 

 

 

$packageID = Read-Host  

 

 

$servername = get-content "C:\Scripts\Dropbox\Scripts\1.txt"  

foreach ($PC in $servername) {

 

   remove-item \\$PC\D$\SMSPKG\$packageID.* 

   remove-item \\$PC\D$\SMSPKGD$\$packageID.*

   remove-item \\$PC\D$\SMSPKGSIG\$packageID.*

   remove-item \\$PC\D$\SMSSIG$\$packageID.*

 

 

I've used Write-Host to see if I have the right server name etc....and I do.   and in fact for my last test I only have ONE server name in the file called 1.txt    yet nothing gets deleted from the remote machine.  How come?

 

 

 

 


Viewing all articles
Browse latest Browse all 8411

Latest Images

Trending Articles



Latest Images