在使用Powershell操作IIsWebVirtualDir(虚拟目录)上的IP限制时遇到问题.
但是,我有在VBS中执行此操作的代码,所以希望这将是一个简单的事情来获得帮助:)
VBS中的代码:
Sub Add2IPRList(WebsiteADSI, strIP2Add, strIP2AddSubnet)
Set WebRootObj = GetObject(WebsiteADSI) '"IIS://localhost/W3SVC/2/ROOT/TestVDIR"
set IPSecObj = WebRootObj.IPSecurity
If(IPSecObj.GrantByDefault)then
IPList = IPSecObj.IPDeny
Else
IPList = IPSecObj.IPGrant
End If
ReDim Preserve IPList (Ubound(IPList)+1) 'resize local copy of IPList array to CurrentSize+1
IPList(Ubound(IPList))=strIP2Add&","&strIP2AddSubnet 'add the entry to the end of the array
If(IPSecObj.GrantByDefault)then
IPSecObj.IPDeny = IPList
Else
IPSecObj.IPGrant = IPList
End If
WebRootObj.IPSecurity = IPSecObj
WebRootObj.SetInfo 'apply the setttings on the server.
set IPSecObj = Nothing
set WebRootObj = Nothing
End Sub
Run Code Online (Sandbox Code Playgroud)
在Powershell中尝试1:对象返回,但是类型很奇怪.
PS …Run Code Online (Sandbox Code Playgroud)