简体   繁体   中英

Set “Allow clients to upload files” for an IIS Virtual Directory using Powershell

I am working on an automated set up of a web server using PowerShell and I need to create a virtual directory which I am able to do using the following code

New-Item 'IIS:\Sites\Default Web Site\folder' -type VirtualDirectory -physicalPath $folder

I also need to set this virtual directory so that it will allow clients to upload files, which can be done manually by opening the BITS Uploads feature and checking the "Allow clients to upload files" check box.

Is there a way to set this using PowerShell?

Thanks in advance

The following example shows how to use PowerShell to enable an IIS virtual directory for BITS uploads. It use System.DirectoryServices to setup virtual directory, it deals with IIS 6 classes, and it also works on IIS 7 if the IIS 6 Management Compatibility feature is installed (see Creating Sites and Virtual Directories Using System.DirectoryServices ).

$root = new-object system.directoryservices.directoryentry("IIS://127.0.0.1/W3SVC/1/Root/folder")
$root.EnableBITSUploads()
#$root.BITSUploadEnabled = $true
#$root.setinfo()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM