Jump to content

Adding Virtual Directories via PowerShell for WebDav, help!


Recommended Posts

Posted

Hello.

 

I'm trying to add virtual directories to my WebDav IIS instance to allow all students WebDav access to their home areas so students can access and save files with iPads etc. Rather than create 800 virtual directories manually obviously scripting is the smart answer. I'm a bit inexperienced with PowerShell so any assistance would be most appreciated. I've gotten a script together and it's parsing the information from the CSV correctly from what I can tell but the error I get is:

 

New-Item : A positional parameter cannot be found that accepts argument '09ansell.jac'.
At C:\webdav\webdav.ps1:14 char:1
+ New-Item 'IIS:\Sites\WebDav\Intake09 Home Area\'$Logon -type VirtualDirectory -p ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : InvalidArgument: ( [New-Item], ParameterBindingException
   + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.NewItemCommand

 

Smells like a Syntax / formatting error to me but I can't seem to find out where, I've tried adding and removing quotes, juggling around the command but to no avail.

 

The script:

 

# Connect to FS
if ( (Get-PSSession -ComputerName fs01.domain) -eq $null)
{
$SessFS01 = New-PSSession  -computername fs01.domain -Authentication 
Kerberos
Import-Module WebAdministration
}


import-CSV intake09test.csv | foreach-object {
$Logon   = $_.Logon
echo $Logon
New-Item 'IIS:\Sites\WebDav\Intake09 Home Area\'$Logon -type VirtualDirectory -physicalPath '\\fs01\09$\'$Logon
}

 

If I run the New-Item command in a Powershell window with the $login variable replaced with a username then the command executes perfectly and creates the virtual directory so there must be something up with how I'm presenting the variables to the script but I can't figure out what.

 

If anyone could help me out with this, it would be extremely appreciated :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...