Code no work, if computer locked

Hello , I used this code, but no work if my computer locked. can you please advise me how to solve the problem? I’m beginner. Thank you.

$Path = "c:\Automat\logs"
$Server = "C:\Users\user\image"

Get-ChildItem ($Path+"\*.*") -Recurse -Exclude *.tif | % {
    Copy-Item -Path $_.FullName -Destination '\\server01\temp\' -Force 
}
Get-ChildItem ($Path+"\*.tif") | %{ 
    $file = new-object System.Drawing.Bitmap($_.FullName); 
    $file.Save(( Join-Path $Server ($_.Name -replace "tif", 'jpg') ),"JPEG");
    $file.dispose();
    sleep(5)
    Remove-Item $_.FullName
}

I thought we already switched to another approach!? :wink:

What about this:

Regardless of that - without more detailed information we are pretty much unable to give a meaningful recommendation. None of the code is actually influenced by the lock state of a computer.

  1. I need copy item from my pc to \server01\temp (without tif images)
  2. Images (format tif) save as jpg to C:\Users\user\image

That shouldn’t be that much of a challenge, right? :wink:

Do you mean to rename or to convert them? Renaming is easy with the cmdlet Rename-Item.

If you want to convert them you will have to use external tools like IrfanView or something similar.

I need convert, because I use jpg on website to lightbox

So you will have to use an external tool of your choice. As far as I know there is no builtin function to convert one picture format into another.