简体   繁体   English

是否会为在Win Server 2008 R2上运行的Windows 7开发PowerShell脚本?

[英]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_NetworkLoginProfileGet-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.

相关问题 更改芬兰语Windows Server 2008 R2上Powershell脚本的文化 - Change culture on Finnish Windows Server 2008 R2 for Powershell Script 如何使用PowerShell脚本在Windows Server 2008 R2上静默安装.NET 4.5。 - How to install .NET 4.5 silently on Windows Server 2008 R2 using powershell Script.? Windows Server 2008 R2 PowerShell和Internet Explorer 9 - Windows Server 2008 R2 PowerShell and Internet Explorer 9 使用Powershell Windows Server 2008 R2将用户导入本地 - Import users to local with powershell windows server 2008 r2 Powershell Win32_OperatingSystem选择标题与操作系统版本“ Microsoft Windows Server 2008 R2 Enterprise”进行比较导致错误的结果 - Powershell Win32_OperatingSystem select Caption compare with OS Version 'Microsoft Windows Server 2008 R2 Enterprise' resulting wrong result Windows Server 2008 R2使用Powershell编辑网络设置 - Windows Server 2008 R2 editing network settings with powershell 在 Windows Server 2008 R2 上的 PowerShell 中创建专用队列 - Creating private queues in PowerShell on Windows Server 2008 R2 使用Powershell激活Windows 2008 R2 Server - Use Powershell to Activate Windows 2008 R2 Server Powershell脚本在Windows 2008 R2上运行良好,但在Windows 2012 R2上不执行任何操作 - Powershell script runs fine on Windows 2008 R2 but does nothing on Windows 2012 R2 Powershell 4与Windows 2008 R2的兼容性 - Powershell 4 compatibility with Windows 2008 r2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM