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

Using $PSScriptRoot to call other scripts

$
0
0

$owners = get-process | Select-Object name, company 

foreach ($owner in $owners) {if ($owner -like '*Sybase*') {Stop-Process -processname $owner.name}}

".\$PSScriptRoot\copy.ps1"

The above code works except for the $PSScriptRoot line.  I get no errors.  But the file copy.ps1 is not being run.  copy.ps1 copies a .txt file from c:\temp7 to c:\temp7\1  and the file never shows up.

when I run copy.ps1 all by itself then the .txt file does copy.      so this seems to be a syntax issue.  I've tried without the double quotes and it gives an error.  If I remove the .\ it fails.   what is the correct syntax?

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles