Will a PowerShell script developed for a Windows 7 run on Win Server 2008 R2? - powershell

I have developed a large PowerShell script that has been refined on a Windows 7 64bit box and now I intend to run it on a Windows server 2008 r2. Assuming the PowerShell versions are the same, will there be any major issues with syntax in-between Win 7 and WS 2008 R2?
The script checks a lot of WMI and registry keys like GWmi Win32_NetworkLoginProfile and Get-Itemproperty -Path Registry::HKLM\Software\Microsoft\"Windows NT"\CurrentVersion\winlogon\
Most PowerShell information is driven towards managing servers so I assume I will be safe, but I want to see if you all can help me learn some lessons before I start banging my head against the wall.
Thanks

There are no syntax differences between PowerShell on Windows 7 and PowerShell on Windows Server 2008 R2. You may encounter differences in existing services, WMI classes, and registry keys, though.

First you should test it on a virtual machine to see if it works or not. Then try it on the physical machine. If it doesn't work, modify the code to the specific registry keys.

The short answer is yes. I run PSv4 on both my desktop and one of my servers running 08. Be sure to import the correct modules (if any) and allow for RPC in your firewall (And winrm) if applicable. One note- depending on what you run with the server, commands and functions are only as good as the version you run against (even when invoked). I ran into this problem as I scripted in v4 and environmentally my firm is almost all v2. Enabled -verbose error output and test in virtual machines or a loner laptop. (This is what I did). Good luck!

Related

Powershell WinRM (WS-manager) service is not running after enabling it in group policy

I need to run remote powershell commands on a 2008 R2 server, so i enabled WinRM using the group policy
but then when i go into windows services to view the running services, the Windows Remote Management (WS-Management) is not on the list
so then when i try to run powershell commands that would setup WinRM
It says that the service is not running, thus i cant register the configuration; which is what i really need since i need to run powershell commands as PS version 2 and not version 3
has anyone encountered this before? does anyone have any idea of where to start looking?
thanks
First, you don't need WinRM or PowerShell remoting to run version 2.0. You just invoke powershell with that version:
powershell.exe -Version 2.0
As to your problem, I am not sure why the service is missing. Since you installed WMF 3/Powershell 3 yourself (I'm assuming, because it's 2008 R2), maybe you can try reinstalling or repairing it? Are there any messages in the event log? I admit I have never seen this before.
Have you used an installer for 2008 R2 that was customized or cut down, like the person who asked this question?

Powershell script to get IIS configuration details

I am looking for fairly generic powerhell cdm allowing me to get the information about IIS - which directory is the log being written to and which fields it is logging.
I need to query circa 400 servers in the environment and check for the differences
We use 2008 r2 with IIS 7
Thanks a lot in advance
Yeah I know IIS has WMI interfaces which are pretty solid. You'll need to look up the classes though.

PowerShell v2 Server 2003 - Cannot Find Path - Path definitely exists

Usually I can find an answer to PowerShell questions by researching forums and adapting. However, after searching high and low, I cannot find an answer.
I am logged in as a domain administrator working on two enterprise servers in a test domain. $Server2003 is Windows 2003 server running PS v2. $Server2008 is Windows 2008 R2.
Problem: When I am working from $Server2003 I cannot use any commands to access or verify information on $Server2008. This error happens regardless of who the administrator is.
I have used PowerShell fairly extensively in our environments and haven't run into this error before. The error is not present when running commands from $Server2008 on $Server2003. In addition the error is not present when running commands from a production domain. I can also ping the 2003 or 2008 server regardless of which machine I am logged in as.
Examples:
From $Server2008: ping $Server2003 - returns pings
From $Server2003: ping $Server2008 - returns pings
From $Server2003: test-path \\$Server2008\D$\ - Get-ChildItem : Cannot find path '\\$Server2008\D$\' because it does not exist
From $Server2008: test-path \\$Server2003\D$\ - True
The commands I want to run are a lot more complex than test-path; however, if I cannot get the simple command to work I doubt I'll have much luck with a complex one.
The two servers have the same domain, are in the same forest, and have the same domain controllers.
Any ideas where to start?
EDIT: Wanted to add that I have tried using test path from Server2003 to a different 2008 server located in our dev environment (same domain) and it runs the test-path and commands successfully.
can you access the 2008 server remotely by other means? Like the Services MMC? Also, what if you create a share on 2008 rather than rely on the admin share?
The cannot find path error means that it doesn't exist or you don't have permissions. Does it work from a dos prompt?
UPDATE
I just noticed that you used single quotes, the variable will not expand. Enclose it in double wotes and try again

Powershell v2 remoting and delegation

I have installed Powershell V2 on 2 machines and run Enable-PsRemoting on both of them. Both machines are Win 2003 R2 and are joined to the same active directory domain and I can successfully run commands remotely. So PS remoting is working between the local server and remote server.
But when I try to access a share on a 3rd server (dir \someOtherServer\builds), which is also Win 2003 R2 and joined to the same active directory, I get the error:
Get-ChildItem : Cannot find path '\someOtherServer\builds' because it does not exist.
So what does it take to get this "hop" to work? Is it the delegation settings (in the active directory) to the remote machine? Are there any settings that can be done when creating a PSSession that will make the hop to work?
I addressed this issue for Workgroups in a blog post. I think the info should apply to domains but I haven't tested in a domain. Anyway, see if it helps. FYI, the solution involves Enable-WSManCredSSP and the Authentication parameter to Enter-PSSession.
It's can be many causes of that. If kerberos auth, check the time on all servers. It must be sync. It may be DNS resolution problem. Need more detailed problem description/
Sorry fo bad english :). If something wrong, please correct me :)

Powershell remoting with V1

Do you know of any good remoting solutions using powershell V1 (I know the V2 stuff is awesome, but my organization doesn't like using pre-release software). I don't need anything spectactular, just a way to kick off powershell script on another box and get the results back when they're done. I'm considering using sysinternals PSEXEC and export-csv/import-csv and just making something that works. I'd rather have someone else do the work, though.
I think PrimalScript's Remote Script Execution Engine would do what you're after. It does require a small service to be installed on remote computers, but you get unlimited licenses for that when you buy PrimalScript (Enterprise edition).
There's also a PSHRemoting project someone did.
N Software's NetCmdlets also come with a "PowerShell Server" (http://nsoftware.com/powershell/) which enables remoting.
There is a great article up on the PowerShell team blog that describes how to get some basic remoting working in V1.
Basically, PS V2 uses Windows Remote Management (WinRM) under the hood. Winrs is the command line tool used to work remotely with machines.
This tactic that Jeffrey talks about uses WinRS and some PowerShell trickery to get remoting working in V1. Its not as slick as V2, but you can definitely get some basic stuff working with it.
I have used PSExec successfully. You can also use WMI to kick off remote processes. Here is an example.
Lee Holmes has posted a solution using PSExec and xml (rather than csv) http://www.leeholmes.com/blog/CategoryView,category,guide.aspx