Use UNC paths for Computers
Something like this
foreach($comp in $computers)
{
Move-Item \\$comp\c$\test\*.log \\$comp\d$\test
$Size = Get-Item \\$comp\d$\test
if ($size.length/1MB -ge 1024)
{
$a = Get-ChildItem \\$comp\d$\test
foreach($x in $a)
{
$y = ((Get-Date) - $x.LastWriteTime).Days
if ($y -ge 10 -and $x.PsISContainer -ne $True)
{$x.Delete()}
}
}
}
Brandon Shell
---------------
Blog:
http://www.bsonposh.com/
PSH Scripts Project:
www.codeplex.com/psobject
R> Hi,
R>
R> I'm trying to find a way to run the following script in multiple
R> remote computers.
R>
R> Move-Item c:\test\*.log d:\test
R> $Size = Get-Item d:\test
R> if ($size.length/1MB -ge 1024)
R> {
R> $a = Get-ChildItem "d:\test"
R> foreach($x in $a)
R> {
R> $y = ((Get-Date) - $x.LastWriteTime).Days
R> if ($y -ge 10 -and $x.PsISContainer -ne $True)
R> {$x.Delete()}
R> }
R> }
R> Can anyone help please. Thanks
R>