-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xWebVirtualDirectory setting PhysicalPath to UNC #94
Comments
I ran a few tests using a UNC directory for the virtual directory and this all works fine for me. For example the bellow example resulted in a virtual directory being created and serving files from the UNC directory. Website = "Default Web Site"
WebApplication = ''
PhysicalPath = "\\IIS02\remote_vdir"
Name = 'UNCExample'
Ensure = 'Present' Could you share what you used? |
In my case, the error occurs with the following configuration: Configuration ConfigurationTest
{
Import-DscResource -Module xWebAdministration
xWebsite DefaultWebSite
{
Ensure = 'Present'
Name = 'Default Web Site'
State = 'Started'
}
Log LogUserName
{
Message = "USERNAME = $env:USERNAME"
}
Script ScriptUserName
{
TestScript =
{
Write-Verbose "USERNAME = $env:USERNAME"
return $true
}
SetScript = { }
GetScript = { @{} }
}
xWebVirtualDirectory NewVirtualDir
{
Name = 'VirtualDirTest'
Website = 'Default Web Site'
WebApplication = ''
PhysicalPath = '\\winserver2012r2disks576.file.core.windows.net\filesharetest'
Ensure = 'Present'
DependsOn = '[xWebsite]DefaultWebSite'
}
} If I am logged as rosberg and my computer name is WinServer2016, the result is:
The log for the resource [Script]ScriptUserName shows that DSC runs under the LocalSystem account. So, the error is probably because you do not have the drive mapped for this user. Configuration ConfigurationTest
{
Import-DscResource –ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName xWebAdministration
xWebsite DefaultWebSite
{
Ensure = 'Present'
Name = 'Default Web Site'
State = 'Started'
}
Script MapDrive
{
TestScript =
{
Test-Path W:
}
SetScript =
{
$acctKey = ConvertTo-SecureString -String "<key>" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential -ArgumentList "Azure\winserver2012r2disks576", $acctKey
New-PSDrive -Name W -PSProvider FileSystem -Root "\\winserver2012r2disks576.file.core.windows.net\filesharetest" -Credential $credential
}
GetScript = { @{} }
}
xWebVirtualDirectory NewVirtualDir
{
Ensure = 'Present'
Name = 'VirtualDirTest'
Website = 'Default Web Site'
WebApplication = ''
PhysicalPath = '\\winserver2012r2disks576.file.core.windows.net\filesharetest'
DependsOn = '[xWebsite]DefaultWebSite', '[Script]MapDrive'
}
} |
@rosberglinhares Maybe the resource should have an option to connect to the UNC path prior setting up the virtual directory? Maybe there could be an credential parameter that triggers this |
- WebVirtualDirectory - Added Credential paramater - Fixed error when using UNC PhysicalPath (issue #94).
Setting a PhysicalPath to UNC for a VirtualDirectory fails.
Perhaps we need to change
New-WebVirtualDirectory -Site $Website -Application $WebApplication -Name $Name -PhysicalPath $PhysicalPath
for
$virtualDirectory = Get-WebVirtualDirectoryInternal -Site $Website -Name $Name -Application $WebApplication
$virtualDirectoryPath = "IIS:\Sites$Website$Name"
New-Item $virtualDirectoryPath -Type VirtualDirectory -PhysicalPath $PhysicalPath
The text was updated successfully, but these errors were encountered: