I have a script that downloads ps1 files to run on new machine start up. I don't want to install any powershell add in or extension methods. I just want to unblock the files and run them. Any suggestions?
$scriptsourcepath = "http://myUrl/"
$scripts = "SQLSetup-Admin.ps1","SQLSetup-NonAdmin.ps1","SQLConfigure.bat"
$downloadpath = "d:\vncutil\"
$clnt = New-Object System.Net.WebClient
foreach($script in $scripts){
$url = $scriptsourcepath + $script
$file = Join-Path $downloadpath $script
$clnt.DownloadFile($url, $file)
}
$batfile = Join-Path $downloadpath "SQLConfigure.bat"
$execStr = '$batfile >>d:\vncutil\SQLConfigure.log'
& $execStr
This post from Scott Hanselman explains how the zone information is embedded in an alternate data stream, you can use that knowledge to unblock your files.
If you are able to use an external tool, the easiest way is to use streams.exe from SysInternals:
streams.exe -d yourscript.ps1
Got the answer on another forum: Not that @driis wasn't on target but this is more powershelly
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.