unblock-file can get rid of prompt warning when try to run ps1 file from internet machine












0














i want to rename photos based on exif data on my remote machine, the code is as follows:



Unblock-File -path ..exif-datetaken.ps1

Get-ChildItem *.jpg | foreach {
#Write-Host "$_`t->`t" -ForegroundColor Cyan -NoNewLine
$date = (..exif-datetaken.ps1 $_.FullName)
if ($date -eq $null) {
Write-Host '{ No ''Date Taken'' in Exif }' -ForegroundColor Cyan
return
}
$newName = $date.ToString('yyyy-MM-dd HH-mm-ss') + $_.extension
$newName = (Join-Path $_.DirectoryName $newName)
Write-Host $newName -ForegroundColor Cyan
mv $_ $newName
}


i use unblock-file to get rid of warning, as i need to click on button to confirm for each photo manually,
but i found unblock-file do not work, i still get that warning prompt,



is it the wrong way to do to resolve this problem ?










share|improve this question






















  • what warning? [grin] some details would likely help a bit ...
    – Lee_Dailey
    Nov 21 at 3:16










  • just run the program you trusted.........., confirm to run \x.x.x.xphotoexif-datetaken.ps1 ? do not run(D), run once(R), suspend(S), i need to press R for each photo, and i also set-executionpolicy unrestricted, but do not work,
    – tonyibm
    Nov 21 at 3:19












  • This is just a guess, but it might be possible that since the powershell script exists on a remote machine and assuming this ip/host is not in your trusted internet zones, it will always be considered untrustworthy. Unrestricted is designed to prompt in cases like these. If you are certain you trust this file, maybe try Set-ExecutionPolicy Bypass instead.
    – RiverHeart
    Nov 21 at 5:30
















0














i want to rename photos based on exif data on my remote machine, the code is as follows:



Unblock-File -path ..exif-datetaken.ps1

Get-ChildItem *.jpg | foreach {
#Write-Host "$_`t->`t" -ForegroundColor Cyan -NoNewLine
$date = (..exif-datetaken.ps1 $_.FullName)
if ($date -eq $null) {
Write-Host '{ No ''Date Taken'' in Exif }' -ForegroundColor Cyan
return
}
$newName = $date.ToString('yyyy-MM-dd HH-mm-ss') + $_.extension
$newName = (Join-Path $_.DirectoryName $newName)
Write-Host $newName -ForegroundColor Cyan
mv $_ $newName
}


i use unblock-file to get rid of warning, as i need to click on button to confirm for each photo manually,
but i found unblock-file do not work, i still get that warning prompt,



is it the wrong way to do to resolve this problem ?










share|improve this question






















  • what warning? [grin] some details would likely help a bit ...
    – Lee_Dailey
    Nov 21 at 3:16










  • just run the program you trusted.........., confirm to run \x.x.x.xphotoexif-datetaken.ps1 ? do not run(D), run once(R), suspend(S), i need to press R for each photo, and i also set-executionpolicy unrestricted, but do not work,
    – tonyibm
    Nov 21 at 3:19












  • This is just a guess, but it might be possible that since the powershell script exists on a remote machine and assuming this ip/host is not in your trusted internet zones, it will always be considered untrustworthy. Unrestricted is designed to prompt in cases like these. If you are certain you trust this file, maybe try Set-ExecutionPolicy Bypass instead.
    – RiverHeart
    Nov 21 at 5:30














0












0








0







i want to rename photos based on exif data on my remote machine, the code is as follows:



Unblock-File -path ..exif-datetaken.ps1

Get-ChildItem *.jpg | foreach {
#Write-Host "$_`t->`t" -ForegroundColor Cyan -NoNewLine
$date = (..exif-datetaken.ps1 $_.FullName)
if ($date -eq $null) {
Write-Host '{ No ''Date Taken'' in Exif }' -ForegroundColor Cyan
return
}
$newName = $date.ToString('yyyy-MM-dd HH-mm-ss') + $_.extension
$newName = (Join-Path $_.DirectoryName $newName)
Write-Host $newName -ForegroundColor Cyan
mv $_ $newName
}


i use unblock-file to get rid of warning, as i need to click on button to confirm for each photo manually,
but i found unblock-file do not work, i still get that warning prompt,



is it the wrong way to do to resolve this problem ?










share|improve this question













i want to rename photos based on exif data on my remote machine, the code is as follows:



Unblock-File -path ..exif-datetaken.ps1

Get-ChildItem *.jpg | foreach {
#Write-Host "$_`t->`t" -ForegroundColor Cyan -NoNewLine
$date = (..exif-datetaken.ps1 $_.FullName)
if ($date -eq $null) {
Write-Host '{ No ''Date Taken'' in Exif }' -ForegroundColor Cyan
return
}
$newName = $date.ToString('yyyy-MM-dd HH-mm-ss') + $_.extension
$newName = (Join-Path $_.DirectoryName $newName)
Write-Host $newName -ForegroundColor Cyan
mv $_ $newName
}


i use unblock-file to get rid of warning, as i need to click on button to confirm for each photo manually,
but i found unblock-file do not work, i still get that warning prompt,



is it the wrong way to do to resolve this problem ?







powershell






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 at 2:54









tonyibm

71211




71211












  • what warning? [grin] some details would likely help a bit ...
    – Lee_Dailey
    Nov 21 at 3:16










  • just run the program you trusted.........., confirm to run \x.x.x.xphotoexif-datetaken.ps1 ? do not run(D), run once(R), suspend(S), i need to press R for each photo, and i also set-executionpolicy unrestricted, but do not work,
    – tonyibm
    Nov 21 at 3:19












  • This is just a guess, but it might be possible that since the powershell script exists on a remote machine and assuming this ip/host is not in your trusted internet zones, it will always be considered untrustworthy. Unrestricted is designed to prompt in cases like these. If you are certain you trust this file, maybe try Set-ExecutionPolicy Bypass instead.
    – RiverHeart
    Nov 21 at 5:30


















  • what warning? [grin] some details would likely help a bit ...
    – Lee_Dailey
    Nov 21 at 3:16










  • just run the program you trusted.........., confirm to run \x.x.x.xphotoexif-datetaken.ps1 ? do not run(D), run once(R), suspend(S), i need to press R for each photo, and i also set-executionpolicy unrestricted, but do not work,
    – tonyibm
    Nov 21 at 3:19












  • This is just a guess, but it might be possible that since the powershell script exists on a remote machine and assuming this ip/host is not in your trusted internet zones, it will always be considered untrustworthy. Unrestricted is designed to prompt in cases like these. If you are certain you trust this file, maybe try Set-ExecutionPolicy Bypass instead.
    – RiverHeart
    Nov 21 at 5:30
















what warning? [grin] some details would likely help a bit ...
– Lee_Dailey
Nov 21 at 3:16




what warning? [grin] some details would likely help a bit ...
– Lee_Dailey
Nov 21 at 3:16












just run the program you trusted.........., confirm to run \x.x.x.xphotoexif-datetaken.ps1 ? do not run(D), run once(R), suspend(S), i need to press R for each photo, and i also set-executionpolicy unrestricted, but do not work,
– tonyibm
Nov 21 at 3:19






just run the program you trusted.........., confirm to run \x.x.x.xphotoexif-datetaken.ps1 ? do not run(D), run once(R), suspend(S), i need to press R for each photo, and i also set-executionpolicy unrestricted, but do not work,
– tonyibm
Nov 21 at 3:19














This is just a guess, but it might be possible that since the powershell script exists on a remote machine and assuming this ip/host is not in your trusted internet zones, it will always be considered untrustworthy. Unrestricted is designed to prompt in cases like these. If you are certain you trust this file, maybe try Set-ExecutionPolicy Bypass instead.
– RiverHeart
Nov 21 at 5:30




This is just a guess, but it might be possible that since the powershell script exists on a remote machine and assuming this ip/host is not in your trusted internet zones, it will always be considered untrustworthy. Unrestricted is designed to prompt in cases like these. If you are certain you trust this file, maybe try Set-ExecutionPolicy Bypass instead.
– RiverHeart
Nov 21 at 5:30












1 Answer
1






active

oldest

votes


















0














Almost any file you download from the web will have ADS (alternate date stream) attached which indicates that it came form the web, and should not be trusted.



You have to use Unblock-File to get rid of that ADS.



If you are doing this for lots of downloaded files, then you have to do that to all of them before take any other actions on them.



ForEach ($TargetPath in $TargetPaths)
{
$TargetPath
Get-ChildItem -Path $TargetPath -Recurse | Unblock-File
Start-Sleep -Seconds 1
}

# Your rename code here


If you are running into prompts, after any downloaded file, then you may need to implement the -Confirm or -Force switch as where prudent.



Unblock-File -Confirm:$false
Rename-Item -Confirm:$false


Unblock is really only needed for downloaded files.
If you are getting other prompts the some lock is on the file or a permission issue. Yet, since you are not showing the error, we are left to guess.






share|improve this answer





















  • thanks a lot, let me try your method,
    – tonyibm
    Nov 21 at 4:11










  • i created file exif-datetaken.ps1, and uploaded to remote machine, then i cd to that remote machine, and run command line code to call that ps1 file, and then i get no-trust warning, need me to manually confirm,
    – tonyibm
    Nov 21 at 4:52










  • i set set-executionpolicy bypass, and now there is no warning
    – tonyibm
    Nov 21 at 5:06










  • Yeppers, that executionpolicy must be set for scripts to run period, well, you could run them in the ISE or VSCode using select all and run selection, but that is a interactive thing only. By default it's set to restricted, and for normal operations should be set to RemoteSigned to allow you to run local scripts. There are little reason to go higher than that level, though you'll see statements, and some docs to use Unrestricted. If you do, you should limit that to your session (process or user). Lots of docs on this setting.
    – postanote
    Nov 22 at 1:40











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404655%2funblock-file-can-get-rid-of-prompt-warning-when-try-to-run-ps1-file-from-interne%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Almost any file you download from the web will have ADS (alternate date stream) attached which indicates that it came form the web, and should not be trusted.



You have to use Unblock-File to get rid of that ADS.



If you are doing this for lots of downloaded files, then you have to do that to all of them before take any other actions on them.



ForEach ($TargetPath in $TargetPaths)
{
$TargetPath
Get-ChildItem -Path $TargetPath -Recurse | Unblock-File
Start-Sleep -Seconds 1
}

# Your rename code here


If you are running into prompts, after any downloaded file, then you may need to implement the -Confirm or -Force switch as where prudent.



Unblock-File -Confirm:$false
Rename-Item -Confirm:$false


Unblock is really only needed for downloaded files.
If you are getting other prompts the some lock is on the file or a permission issue. Yet, since you are not showing the error, we are left to guess.






share|improve this answer





















  • thanks a lot, let me try your method,
    – tonyibm
    Nov 21 at 4:11










  • i created file exif-datetaken.ps1, and uploaded to remote machine, then i cd to that remote machine, and run command line code to call that ps1 file, and then i get no-trust warning, need me to manually confirm,
    – tonyibm
    Nov 21 at 4:52










  • i set set-executionpolicy bypass, and now there is no warning
    – tonyibm
    Nov 21 at 5:06










  • Yeppers, that executionpolicy must be set for scripts to run period, well, you could run them in the ISE or VSCode using select all and run selection, but that is a interactive thing only. By default it's set to restricted, and for normal operations should be set to RemoteSigned to allow you to run local scripts. There are little reason to go higher than that level, though you'll see statements, and some docs to use Unrestricted. If you do, you should limit that to your session (process or user). Lots of docs on this setting.
    – postanote
    Nov 22 at 1:40
















0














Almost any file you download from the web will have ADS (alternate date stream) attached which indicates that it came form the web, and should not be trusted.



You have to use Unblock-File to get rid of that ADS.



If you are doing this for lots of downloaded files, then you have to do that to all of them before take any other actions on them.



ForEach ($TargetPath in $TargetPaths)
{
$TargetPath
Get-ChildItem -Path $TargetPath -Recurse | Unblock-File
Start-Sleep -Seconds 1
}

# Your rename code here


If you are running into prompts, after any downloaded file, then you may need to implement the -Confirm or -Force switch as where prudent.



Unblock-File -Confirm:$false
Rename-Item -Confirm:$false


Unblock is really only needed for downloaded files.
If you are getting other prompts the some lock is on the file or a permission issue. Yet, since you are not showing the error, we are left to guess.






share|improve this answer





















  • thanks a lot, let me try your method,
    – tonyibm
    Nov 21 at 4:11










  • i created file exif-datetaken.ps1, and uploaded to remote machine, then i cd to that remote machine, and run command line code to call that ps1 file, and then i get no-trust warning, need me to manually confirm,
    – tonyibm
    Nov 21 at 4:52










  • i set set-executionpolicy bypass, and now there is no warning
    – tonyibm
    Nov 21 at 5:06










  • Yeppers, that executionpolicy must be set for scripts to run period, well, you could run them in the ISE or VSCode using select all and run selection, but that is a interactive thing only. By default it's set to restricted, and for normal operations should be set to RemoteSigned to allow you to run local scripts. There are little reason to go higher than that level, though you'll see statements, and some docs to use Unrestricted. If you do, you should limit that to your session (process or user). Lots of docs on this setting.
    – postanote
    Nov 22 at 1:40














0












0








0






Almost any file you download from the web will have ADS (alternate date stream) attached which indicates that it came form the web, and should not be trusted.



You have to use Unblock-File to get rid of that ADS.



If you are doing this for lots of downloaded files, then you have to do that to all of them before take any other actions on them.



ForEach ($TargetPath in $TargetPaths)
{
$TargetPath
Get-ChildItem -Path $TargetPath -Recurse | Unblock-File
Start-Sleep -Seconds 1
}

# Your rename code here


If you are running into prompts, after any downloaded file, then you may need to implement the -Confirm or -Force switch as where prudent.



Unblock-File -Confirm:$false
Rename-Item -Confirm:$false


Unblock is really only needed for downloaded files.
If you are getting other prompts the some lock is on the file or a permission issue. Yet, since you are not showing the error, we are left to guess.






share|improve this answer












Almost any file you download from the web will have ADS (alternate date stream) attached which indicates that it came form the web, and should not be trusted.



You have to use Unblock-File to get rid of that ADS.



If you are doing this for lots of downloaded files, then you have to do that to all of them before take any other actions on them.



ForEach ($TargetPath in $TargetPaths)
{
$TargetPath
Get-ChildItem -Path $TargetPath -Recurse | Unblock-File
Start-Sleep -Seconds 1
}

# Your rename code here


If you are running into prompts, after any downloaded file, then you may need to implement the -Confirm or -Force switch as where prudent.



Unblock-File -Confirm:$false
Rename-Item -Confirm:$false


Unblock is really only needed for downloaded files.
If you are getting other prompts the some lock is on the file or a permission issue. Yet, since you are not showing the error, we are left to guess.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 at 4:09









postanote

3,0811410




3,0811410












  • thanks a lot, let me try your method,
    – tonyibm
    Nov 21 at 4:11










  • i created file exif-datetaken.ps1, and uploaded to remote machine, then i cd to that remote machine, and run command line code to call that ps1 file, and then i get no-trust warning, need me to manually confirm,
    – tonyibm
    Nov 21 at 4:52










  • i set set-executionpolicy bypass, and now there is no warning
    – tonyibm
    Nov 21 at 5:06










  • Yeppers, that executionpolicy must be set for scripts to run period, well, you could run them in the ISE or VSCode using select all and run selection, but that is a interactive thing only. By default it's set to restricted, and for normal operations should be set to RemoteSigned to allow you to run local scripts. There are little reason to go higher than that level, though you'll see statements, and some docs to use Unrestricted. If you do, you should limit that to your session (process or user). Lots of docs on this setting.
    – postanote
    Nov 22 at 1:40


















  • thanks a lot, let me try your method,
    – tonyibm
    Nov 21 at 4:11










  • i created file exif-datetaken.ps1, and uploaded to remote machine, then i cd to that remote machine, and run command line code to call that ps1 file, and then i get no-trust warning, need me to manually confirm,
    – tonyibm
    Nov 21 at 4:52










  • i set set-executionpolicy bypass, and now there is no warning
    – tonyibm
    Nov 21 at 5:06










  • Yeppers, that executionpolicy must be set for scripts to run period, well, you could run them in the ISE or VSCode using select all and run selection, but that is a interactive thing only. By default it's set to restricted, and for normal operations should be set to RemoteSigned to allow you to run local scripts. There are little reason to go higher than that level, though you'll see statements, and some docs to use Unrestricted. If you do, you should limit that to your session (process or user). Lots of docs on this setting.
    – postanote
    Nov 22 at 1:40
















thanks a lot, let me try your method,
– tonyibm
Nov 21 at 4:11




thanks a lot, let me try your method,
– tonyibm
Nov 21 at 4:11












i created file exif-datetaken.ps1, and uploaded to remote machine, then i cd to that remote machine, and run command line code to call that ps1 file, and then i get no-trust warning, need me to manually confirm,
– tonyibm
Nov 21 at 4:52




i created file exif-datetaken.ps1, and uploaded to remote machine, then i cd to that remote machine, and run command line code to call that ps1 file, and then i get no-trust warning, need me to manually confirm,
– tonyibm
Nov 21 at 4:52












i set set-executionpolicy bypass, and now there is no warning
– tonyibm
Nov 21 at 5:06




i set set-executionpolicy bypass, and now there is no warning
– tonyibm
Nov 21 at 5:06












Yeppers, that executionpolicy must be set for scripts to run period, well, you could run them in the ISE or VSCode using select all and run selection, but that is a interactive thing only. By default it's set to restricted, and for normal operations should be set to RemoteSigned to allow you to run local scripts. There are little reason to go higher than that level, though you'll see statements, and some docs to use Unrestricted. If you do, you should limit that to your session (process or user). Lots of docs on this setting.
– postanote
Nov 22 at 1:40




Yeppers, that executionpolicy must be set for scripts to run period, well, you could run them in the ISE or VSCode using select all and run selection, but that is a interactive thing only. By default it's set to restricted, and for normal operations should be set to RemoteSigned to allow you to run local scripts. There are little reason to go higher than that level, though you'll see statements, and some docs to use Unrestricted. If you do, you should limit that to your session (process or user). Lots of docs on this setting.
– postanote
Nov 22 at 1:40


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404655%2funblock-file-can-get-rid-of-prompt-warning-when-try-to-run-ps1-file-from-interne%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python