We help IT Professionals succeed at work.

Domain start up script powershell

Lofty Worm
Lofty Worm asked
on
So, I use batch files for our start up scripts.  Nothing required, just run.

If I wanted to start using powershell, what would be required?
Install PS for sure.
but do I need to touch every server and say it is ok to run PS scripts?
If so, can I embed that in the script or command someplace?
Comment
Watch Question

Meir RivkinFull stack Software Engineer

Commented:
which OS u use?
Windows PowerShell 1.0 is available as a download or can be evaluated as part of Windows Server 2008 evaluation versions.
you can download Windows PowerShell 1.0 for Windows XP SP2, Windows Server 2003 or Windows Vista here http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx.

then u first need to run the following:
powershell Set-ExecutionPolicy <policy>
The Set-ExecutionPolicy cmdlet enables you to determine which Windows PowerShell scripts (if any) will be allowed to run on your computer.
you have 4 different policies: Restricted,Unrestricted, AllSigned, RemoteSigned
check here for details: http://technet.microsoft.com/en-us/library/ee176961.aspx

when running Set-ExecutionPolicy command you may encounter the following error:
"Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied."
The overcome this error simply start PowerShell as an Administrator and then run the command.
just right-clicking the PowerShell icon in the Start Menu and selecting "Run as Administrator".



Chris DentPowerShell Developer
Top Expert 2010

Commented:

I suggest you skip PowerShell 1 entirely and go for 2:

http://support.microsoft.com/kb/968929

It's pre-installed on Windows 7 and 2008 R2. It can also be pushed out using WSUS if you have that.

When do you need your script to do? And what operating system are your clients running?

Chris

Author

Commented:
Ty for your replies, I already have powershell installed across 2003 and 2008 system wide.  I want to start using powershell instead of batch files for our GPO startup scripts.  Specifically because I want to run the following script and it will be easier to write in PS.  In order for PS to work with scripts, I know about the execution policy, but do NOT want to touch 300+ servers to run a command so scripts can run, so how do I get around this?

check for file
if file exists then eof
if 2008 then goto 2008
else
do an inventory
copy inventory to :
add users to groups
add machine name to collectorlist
create file
goto eof
2008 label
repeat above for 2008
PowerShell Developer
Top Expert 2010
Commented:

MS to the rescue ;)

Grab this and set the execution policy setting through Group Policy:

http://www.microsoft.com/downloads/details.aspx?FamilyID=2917a564-dbbc-4da7-82c8-fe08b3ef4e6d&DisplayLang=en#QuickInfoContainer

It has the paths to the policies under Additional Information.

Chris

Author

Commented:
nice :)  I will look into this, and re post soon