Trying to create application to

This topic contains 2 replies, has 2 voices, and was last updated by  Jeremy Corbello 4 months, 2 weeks ago.

  • Author
  • #90857

    Karl Ng


    I am trying create a script that copies a file from the current directory and sends it to a path. I tried to use .\ this script works if I type a the full path name. THe powershell script and the file would be in the same directory and sccm would download it locally and run it locally. The source path can not be static because the source could be different on every machine.

    The script below. I changed the source path for security purposes.

    path = "D:\install\support\logon\scripts"
    If(!(test-path $path))
    New-Item -ItemType Directory -Force -Path $path

    $Source = "\\\TEST"
    $Destination = "D:\install\support\logon\Scripts\"

    $ExcludeItems = @()
    if (Test-Path "$Destination\*.dli")
    $ExcludeItems += "*.dli"


    Copy-Item "$Source\*" -Destination "$Destination" -Exclude $ExcludeItems -Recurse -Force

  • #90860

    Jeremy Corbello

    Just want to verify, the $Source variable is what you're trying to dot-source, right?

    • #90863

      Jeremy Corbello

      Let me elaborate a little more.
      When you run a script and .\ a location, it .\ in the default directory, not necessarily the invocation path. (Someone can correct me if I'm mistaken here)

      Instead of .\, try something like this:

      $Source = Split-Path -Parent $MyInvocation.MyCommand.Path

You must be logged in to reply to this topic.