Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 在Windows Server 2008 R2中使用新的WebVirtualDirectory_Powershell_Windows Server 2008 - Fatal编程技术网

Powershell 在Windows Server 2008 R2中使用新的WebVirtualDirectory

Powershell 在Windows Server 2008 R2中使用新的WebVirtualDirectory,powershell,windows-server-2008,Powershell,Windows Server 2008,我需要使用powershell脚本在多台计算机中创建一些虚拟目录,但这些计算机具有不同的Windows Server版本 PS> Import-Module webadministration PS> New-Item 'IIS:\Sites\Default Web Site\my_app\dir_name' -physicalPath "D:\pyhiscal_dir" -type VirtualDirectory 最旧的是Windows Server 2008 R2,我认为cm

我需要使用powershell脚本在多台计算机中创建一些虚拟目录,但这些计算机具有不同的Windows Server版本

PS> Import-Module webadministration
PS> New-Item 'IIS:\Sites\Default Web Site\my_app\dir_name' -physicalPath "D:\pyhiscal_dir" -type VirtualDirectory
最旧的是Windows Server 2008 R2,我认为cmdlet新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版本兼容的完美替代方案

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

我在这个网站上几乎找到了一些例子。这给了我线索。谢谢@Jawad,我将发布一个答案来解释真正的替代方案。