【问题标题】:Using New-WebVirtualDirectory in Windows Server 2008 R2 [duplicate]在 Windows Server 2008 R2 中使用 New-WebVirtualDirectory [重复]
【发布时间】:2020-06-10 05:28:49
【问题描述】:

我需要使用 powershell 脚本在几台机器上创建一些虚拟目录,但是这些机器有不同的 Windows Server 版本。

最早的是 Windows Server 2008 R2,我认为 cmdlet New-WebVirtualDirectory 仅在 Windows Server 2012 之后才可用。

如何才能兼容 Windows 2008-R2 到 2019?我无法控制升级这些旧服务器和它们的 powershell 版本...

我需要与此等价的:

New-WebVirtualDirectory -Site "Default Web Site" -Application my_app -Name dir_name -PhysicalPath "D:\pyhiscal_dir"

【问题讨论】:

  • 差不多。这给了我线索。谢谢@Jawad,我会发布一个答案来解释真正的替代方案。

标签: powershell windows-server-2008


【解决方案1】:

感谢 Jawad,我找到了兼容每个 powershell 版本的完美替代方案。

PS> Import-Module webadministration
PS> New-Item 'IIS:\Sites\Default Web Site\my_app\dir_name' -physicalPath "D:\pyhiscal_dir" -type VirtualDirectory

我在这个网站Creating Websites, Web apps, Virtual Dirs and App Pools找到了一些例子

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-01
    • 1970-01-01
    • 2012-06-05
    相关资源
    最近更新 更多