Powershell SEcurity Warning Message help needed

Windows 7 Pro

Powershell v1.0

When in powershell
I change directory to c:\util  where I have a script  Get-PendingReboot.ps1
then I ran this ./get-pendingreboot.ps1
I would get a message that the script was not digitally signed

So I found this command

set-executionpolicy unrestricted

Now when I run ./get-pendingreboot.ps1

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
computer. Do you want to run C:\util\Get-PendingReboot.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): r

I get this warning everytime

Also I get no output from the script

1. How to stp the warning message

2. how to get output tp display

The script came from this
https://gallery.technet.microsoft.com/scriptcenter/Get-PendingReboot-Query-bdb79542


Thoughts

Thanks

tom
LVL 23
Thomas GrassiSystems AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

footechCommented:
Set your execution policy to "RemoteSigned".  When set to "Unrestricted" you will always get the warning.

The script just loads the function.  Afterward you need to run the function.
You should dot-source the script to load it into the global scope.
. .\get-pendingreboot.ps1

Open in new window


Then run the function.
Get-PendingReboot

Open in new window


And by the way, Win7 comes with PS 2.0.  :)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Thomas GrassiSystems AdministratorAuthor Commented:
footech

Thanks for the fast response


I ran this first set-executionpolicy  remotesigned        now no security warning message

PS C:\util> ..\get-pendingreboot.ps1
..\get-pendingreboot.ps1 : The term '..\get-pendingreboot.ps1' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ ..\get-pendingreboot.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (..\get-pendingreboot.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


When I tried this  with a space between the two dots which is what it looks like in your post either way does not work

PS C:\util> . .\get-pendingreboot.ps1
. : File C:\util\Get-PendingReboot.ps1 cannot be loaded. The file C:\util\Get-PendingReboot.ps1 is not digitally
signed. The script will not execute on the system. For more information, see about_Execution_Policies at
http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ . .\get-pendingreboot.ps1
+   ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess


What am I missing here?

Thanks
Will SzymkowskiSenior Solution ArchitectCommented:
As Footech stated the most appropriate Execution Policy to run is "Remote Signed".

You need to only run the script like below

.\PendingReboot.ps1

Open in new window


You also need to be in the same path where the script is located. You do not use double periods.

Will.
footechCommented:
With RemoteSigned, it means that files detected as being from the internet (i.e. "remote") should be digitally signed.  You need to unblock the file so that it is no longer detected as such.  There in an Unblock-File cmdlet with PS 3.0+, or you can go to the file's properties and click the Unblock button.
file properties
And yes, there is a space after the first dot.
There are other ways of dealing with scope, but this is the easiest to get you working.  And remember, running the file just loads the function - you will have to run it after.  The page where you downloaded the script from describes this.
Thomas GrassiSystems AdministratorAuthor Commented:
This is how it works

.  ./Get-PendingReboot.ps1
Get-PendingReboot -ComputerName SERV011, SERV012


Thanks for all the help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.