[英]Will a PowerShell script developed for a Windows 7 run on Win Server 2008 R2?
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. 我开发了一个大型PowerShell脚本,该脚本已在Windows 7 64位盒子上进行了改进,现在我打算在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?
假设PowerShell版本相同,Win 7和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\\
该脚本检查许多WMI和注册表项,如
GWmi Win32_NetworkLoginProfile
和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. 大多数PowerShell信息都是为了管理服务器,因此我认为我会安全,但我想看看你们是否能够帮助我学习一些课程,然后才开始敲打我的脑袋。 Thanks
谢谢
There are no syntax differences between PowerShell on Windows 7 and PowerShell on Windows Server 2008 R2. Windows 7上的PowerShell与Windows Server 2008 R2上的PowerShell之间没有语法差异。 You may encounter differences in existing services, WMI classes, and registry keys, though.
但是,您可能会遇到现有服务,WMI类和注册表项的差异。
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.
我在我的桌面和我的一台运行08的服务器上运行PSv4。确保导入正确的模块(如果有的话),并允许在防火墙(和winrm)中使用RPC(如果适用)。 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.
我遇到了这个问题,因为我在v4中编写脚本,而环境保护我的公司几乎都是v2。 Enabled -verbose error output and test in virtual machines or a loner laptop.
在虚拟机或孤独的笔记本电脑中启用-verbose错误输出和测试。 (This is what I did).
(这就是我所做的)。 Good luck!
祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.