PowerShell script 'cannot find path' when deployed by PDQ

Comments

7 comments

  • Colby Bouma

    I think you may have a copy/paste error. $WINDOWS does not exist, that's why the evaluated line becomes \.~BT\

    >Cannot find path '\\nameOfComputerHere\c$\.~BT\Sources\Panther\setupact.log'

    0
    Comment actions Permalink
  • xela citnad

    Appreciate the brief response Colby. 

    I saw that too, but looking at my PowerShell script $WINDOWS is clearly there.  

    It's odd because for a test, I moved the setupact.log file out of the $WINDOWS.~BT directory and into the C: drive and PDQ deployed it successfully which makes me want to believe there's something up wi/ the $WINDOWS.~BT directory that it doesn't like.  

    Like I mentioned, when I run it manually, through PowerShell, it works just fine, however I want to use PDQ Deploy because choosing the target makes it easier for filling in the env:COMPUTERNAME variable.  

    Thoughts?

    0
    Comment actions Permalink
  • Colby Bouma

    Can you share the whole script you're trying to run?

    0
    Comment actions Permalink
  • xela citnad

    Sure thing:

     

    $msg = new-object Net.Mail.MailMessage
    $smtp = new-object Net.Mail.SmtpClient("smtp.domain.com")
    $msg.From = "e-mail@domain.com"
    $msg.ReplyTo = "e-mail@domain.com"
    $msg.To.Add("support@domain.com")
    $msg.subject = "Upgrade Errors"
    $send = gc \\$env:COMPUTERNAME\c$\$WINDOWS.~BT\Sources\Panther\setupact.log | Select-String uninstall
    $body = @"
    $send
    "@
    $msg.body += $body
    $smtp.Send($msg)

     

    0
    Comment actions Permalink
  • xela citnad

    Just wanted to follow up & see if you were able to take a look at the whole script.  Let me know.  Thanks again !!

    0
    Comment actions Permalink
  • Colby Bouma

    Ah, it looks like the folder name actually starts with $. PowerShell interprets anything that starts with $ as a variable, so you have to escape the $ with `.

    $send = gc "\\$env:COMPUTERNAME\c$\`$WINDOWS.~BT\Sources\Panther\setupact.log" | Select-String uninstall

     

    1
    Comment actions Permalink
  • xela citnad

    That worked.  Can't thank you enough.

    0
    Comment actions Permalink

Please sign in to leave a comment.