Powershell & IIS 7.5 FTP virtualdirectories


situation:

-mainftp
   -usera (virtual folder)
   -userb (virtual folder)
   -userc (virtual folder)

when these folders beeing created manually, can change default allow rule(configured on mainftp) read read,write
there 1 rule, after doing so

now when try in powershel looks bit diffrent...

creating virtual directory:

 

  import-module webadministration  new-item 'iis:\sites\mainftp\usera' -type virtualdirectory -physicalpath c:\temp  

now can see allow rule read, because it´s default.

what set read, write i´m trying this:

set-webconfiguration -filter /system.ftpserver/security/authorization -value (@{accesstype="allow"; users="*"; permissions="read, write"}) -pspath iis: -location "mainftp/usera"

but throws error key missing.... don´t know which? anyone? idea?

 

what tried set adding new rule:

  add-webconfiguration -filter /system.ftpserver/security/authorization -value (@{accesstype="allow"; users="*"; permissions="read, write"}) -pspath iis: -location "mainftp/usera"  

that worked have 2 allow-rules 1 read , 1 read,write....

 

my question is.

has idea on how can "set"-option working?
or have better way? maybe using api?

 

 

 

  # worked out in end..... # kloinerfeigling # 9th nov 2010 [system.reflection.assembly]::loadwithpartialname("microsoft.web.administration")  $iis = new-object microsoft.web.administration.servermanager  $config = $iis.getapplicationhostconfiguration() $authorizationsection = $config.getsection("system.ftpserver/security/authorization","mainftp/usera") $authorizationsection $authorizationcollection = $authorizationsection.getcollection(); ####you can use $authorizationcollection[0] works in case $element = $authorizationcollection[0] $attribute = $element.attributes["users"] write-output "if there no * it´s not users" + $attribute.value.tostring() if ($attribute.value.tostring() -eq "*")     {       write-output "vorher" + $element["permissions"] 		  $element["permissions"] = "read, write" 		  $iis.commitchanges()       write-output "nach dem setzen:" + $element["permissions"] 		       }  ##or can go through itemas in foreach , check * = allusers foreach ($element in $authorizationcollection)   {     $attribute = $element.attributes["users"];     if ($attribute.value.tostring() -eq "*")     {       write-output "vorher" + $element["permissions"] 		  $element["permissions"] = "read, write" 		  $iis.commitchanges()       write-output "nach dem setzen:" + $element["permissions"]     }   }  

i worked out , guess what, doesn´t create additional rule modifies existing 1 in gui, seems using set-webconfiguration somehow doesn´t work.

@ms bug? or unwanted feature?



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2