有没有一种方法可以检查正在运行PowerShell脚本的操作系统,并发出一条If声明:
[伪代码]
if its this OS
do this
if its this other OS
do this
Run Code Online (Sandbox Code Playgroud)
仅针对脚本中的特定行?我必须制作一个设置私人消息队列的PowerShell脚本。遗憾的是,我公司的某些客户端未使用Windows Server 2012,因此添加私有消息队列的更简单版本无法在Windows Server 2008和过时的PowerShell版本上使用。要解决此问题,我还必须改用非常复杂的旧方法,但是我希望这两种方法都存在。