xWebVirtualDirectory: Must specify '/' for WebApplication when virtual directory is under the website
Hello,
When running the resource with 'Absent' flag, I'm getting the following error:
##[error]PowerShell Desired State Configuration does not support execution of commands in an interactive mode. Please ensure that the underlying command is not prompting for user input, such as missing mandatory parameter, confirmation prompt etc. + CategoryInfo : NotSpecified: (:) [], CimException + FullyQualifiedErrorId : System.NotSupportedException,Microsoft.IIs.PowerShell.Provider.RemoveVirtualDirectoryCom mand + PSComputerName : IPAddress
'Ensure' works perfectly but when I run it with 'Absent' it brings up the above error.
Appreciate your assistance, David
Could you please provide the verbose output and your configuration? Both with the sensitive information obfuscated.
Hello johlju,
Thank you for your quick response.
Note that the problematic is Vd1.
Verbose output of the xWebVirtualDirectory section
2018-06-10T14:47:45.0167701Z VERBOSE: [ServerName]: LCM: [ Start Resource ] [[xWebVirtualDirectory]Vd1]
2018-06-10T14:47:45.0167701Z VERBOSE: [ServerName]: LCM: [ Start Test ] [[xWebVirtualDirectory]Vd1]
2018-06-10T14:47:45.0636518Z VERBOSE: [ServerName]: LCM: [ End Test ] [[xWebVirtualDirectory]Vd1] in 0.0780 seconds.
2018-06-10T14:47:45.0636518Z VERBOSE: [ServerName]: LCM: [ Start Set ] [[xWebVirtualDirectory]Vd1]
2018-06-10T14:47:45.1104968Z VERBOSE: [ServerName]: [[xWebVirtualDirectory]Vd1] Removing existing Virtual Directory "Vd1".
2018-06-10T14:47:45.4386355Z ##[error]PowerShell Desired State Configuration does not support execution of commands in an interactive mode. Please ensure
that the underlying command is not prompting for user input, such as missing mandatory parameter, confirmation prompt
etc.
+ CategoryInfo : NotSpecified: (:) [], CimException
+ FullyQualifiedErrorId : System.NotSupportedException,Microsoft.IIs.PowerShell.Provider.RemoveVirtualDirectoryCom
mand
+ PSComputerName : x.x.x.x
2018-06-10T14:47:45.4542634Z VERBOSE: [ServerName]: LCM: [ End Set ] [[xWebVirtualDirectory]Vd1] in 0.1870 seconds.
2018-06-10T14:47:45.4698911Z ##[error]The PowerShell DSC resource '[xWebVirtualDirectory]i' with SourceInfo
'D:\PathToScript\WebSite.ps1::804::13::xWebVirtualDirectory' threw one or more
non-terminating errors while running the Set-TargetResource functionality. These errors are logged to the ETW channel
called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : NonTerminatingErrorFromProvider
+ PSComputerName : x.x.x.x
2018-06-10T14:47:45.4698911Z VERBOSE: [ServerName]: LCM: [ Start Resource ] [[xWebVirtualDirectory]Vd2]
2018-06-10T14:47:45.4698911Z VERBOSE: [ServerName]: LCM: [ Start Test ] [[xWebVirtualDirectory]Vd2]
2018-06-10T14:47:45.4698911Z VERBOSE: [ServerName]: [[xWebVirtualDirectory]Vd2] Physical path
2018-06-10T14:47:45.4698911Z "\\ServerName\PathToVd2" for web virtual directory "Vd2" does not match desired
2018-06-10T14:47:45.4698911Z state.
2018-06-10T14:47:45.4698911Z VERBOSE: [ServerName]: LCM: [ End Test ] [[xWebVirtualDirectory]Vd2] in 0.0470 seconds.
2018-06-10T14:47:45.4698911Z VERBOSE: [ServerName]: LCM: [ Start Set ] [[xWebVirtualDirectory]Vd2]
2018-06-10T14:47:45.4698911Z VERBOSE: [ServerName]: [[xWebVirtualDirectory]Vd2] Updating physical path for web virtual
2018-06-10T14:47:45.4698911Z directory "Vd2".
2018-06-10T14:47:45.4698911Z VERBOSE: [ServerName]: LCM: [ End Set ] [[xWebVirtualDirectory]Vd2] in 0.1090 seconds.
2018-06-10T14:47:45.4698911Z VERBOSE: [ServerName]: LCM: [ End Resource ] [[xWebVirtualDirectory]Vd2]
2018-06-10T14:47:45.4855009Z VERBOSE: [ServerName]: LCM: [ Start Resource ] [[xWebVirtualDirectory]Vd3]
2018-06-10T14:47:45.4855009Z VERBOSE: [ServerName]: LCM: [ Start Test ] [[xWebVirtualDirectory]Vd3]
2018-06-10T14:47:45.5480256Z VERBOSE: [ServerName]: [[xWebVirtualDirectory]Vd3] Web virtual directory is in required
2018-06-10T14:47:45.5480256Z state.
2018-06-10T14:47:45.5480256Z VERBOSE: [ServerName]: LCM: [ End Test ] [[xWebVirtualDirectory]Vd3] in 0.0630 seconds.
2018-06-10T14:47:45.5480256Z VERBOSE: [ServerName]: LCM: [ Skip Set ] [[xWebVirtualDirectory]Vd3]
2018-06-10T14:47:45.5480256Z VERBOSE: [ServerName]: LCM: [ End Resource ] [[xWebVirtualDirectory]Vd3]
2018-06-10T14:47:45.5636398Z VERBOSE: [ServerName]: LCM: [ Start Resource ] [[xWebVirtualDirectory]vd4]
2018-06-10T14:47:45.5636398Z VERBOSE: [ServerName]: LCM: [ Start Test ] [[xWebVirtualDirectory]vd4]
2018-06-10T14:47:45.5949062Z VERBOSE: [ServerName]: [[xWebVirtualDirectory]vd4] Web virtual directory is in required
2018-06-10T14:47:45.5949062Z state.
2018-06-10T14:47:45.5949062Z VERBOSE: [ServerName]: LCM: [ End Test ] [[xWebVirtualDirectory]vd4] in 0.0620 seconds.
2018-06-10T14:47:45.5949062Z VERBOSE: [ServerName]: LCM: [ Skip Set ] [[xWebVirtualDirectory]vd4]
2018-06-10T14:47:45.5949062Z VERBOSE: [ServerName]: LCM: [ End Resource ] [[xWebVirtualDirectory]vd4]
2018-06-10T14:47:45.6105215Z VERBOSE: [ServerName]: LCM: [ Start Resource ] [[xWebVirtualDirectory]vd5]
2018-06-10T14:47:45.6105215Z VERBOSE: [ServerName]: LCM: [ Start Test ] [[xWebVirtualDirectory]vd5]
2018-06-10T14:47:45.6417822Z VERBOSE: [ServerName]: [[xWebVirtualDirectory]vd5] Web virtual directory is in required
2018-06-10T14:47:45.6417822Z state.
2018-06-10T14:47:45.6417822Z VERBOSE: [ServerName]: LCM: [ End Test ] [[xWebVirtualDirectory]vd5] in 0.0470 seconds.
2018-06-10T14:47:45.6417822Z VERBOSE: [ServerName]: LCM: [ Skip Set ] [[xWebVirtualDirectory]vd5]
2018-06-10T14:47:45.6417822Z VERBOSE: [ServerName]: LCM: [ End Resource ] [[xWebVirtualDirectory]vd5]
2018-06-10T14:47:45.6730704Z VERBOSE: [ServerName]: LCM: [ Start Resource ] [[xWebVirtualDirectory]vd6]
2018-06-10T14:47:45.6730704Z VERBOSE: [ServerName]: LCM: [ Start Test ] [[xWebVirtualDirectory]vd6]
2018-06-10T14:47:45.6886510Z VERBOSE: [ServerName]: [[xWebVirtualDirectory]vd6] Web virtual directory is in required
2018-06-10T14:47:45.6886510Z state.
2018-06-10T14:47:45.7042641Z VERBOSE: [ServerName]: LCM: [ End Test ] [[xWebVirtualDirectory]vd6] in 0.0470 seconds.
2018-06-10T14:47:45.7042641Z VERBOSE: [ServerName]: LCM: [ Skip Set ] [[xWebVirtualDirectory]vd6]
2018-06-10T14:47:45.7042641Z VERBOSE: [ServerName]: LCM: [ End Resource ] [[xWebVirtualDirectory]vd6]
2018-06-10T14:47:45.7198852Z VERBOSE: [ServerName]: LCM: [ Start Resource ] [[xWebVirtualDirectory]vd7]
2018-06-10T14:47:45.7198852Z VERBOSE: [ServerName]: LCM: [ Start Test ] [[xWebVirtualDirectory]vd7]
2018-06-10T14:47:45.7511513Z VERBOSE: [ServerName]: [[xWebVirtualDirectory]vd7] Web virtual directory is in required state.
2018-06-10T14:47:45.7511513Z VERBOSE: [ServerName]: LCM: [ End Test ] [[xWebVirtualDirectory]vd7] in 0.0470 seconds.
2018-06-10T14:47:45.7511513Z VERBOSE: [ServerName]: LCM: [ Skip Set ] [[xWebVirtualDirectory]vd7]
2018-06-10T14:47:45.7511513Z VERBOSE: [ServerName]: LCM: [ End Resource ] [[xWebVirtualDirectory]vd7]
2018-06-10T14:47:45.7667672Z VERBOSE: [ServerName]: LCM: [ Start Resource ] [[xWebVirtualDirectory]vd8]
2018-06-10T14:47:45.7667672Z VERBOSE: [ServerName]: LCM: [ Start Test ] [[xWebVirtualDirectory]vd8]
2018-06-10T14:47:45.7980302Z VERBOSE: [ServerName]: [[xWebVirtualDirectory]vd8] Web virtual directory is in required
2018-06-10T14:47:45.7980302Z state.
2018-06-10T14:47:45.7980302Z VERBOSE: [ServerName]: LCM: [ End Test ] [[xWebVirtualDirectory]vd8] in 0.0470 seconds.
2018-06-10T14:47:45.7980302Z VERBOSE: [ServerName]: LCM: [ Skip Set ] [[xWebVirtualDirectory]vd8]
2018-06-10T14:47:45.7980302Z VERBOSE: [ServerName]: LCM: [ End Resource ] [[xWebVirtualDirectory]vd8]
2018-06-10T14:47:45.8136493Z VERBOSE: [ServerName]: LCM: [ Start Resource ] [[Script]SetVirtualDirectoriesDefaults]
2018-06-10T14:47:45.8136493Z VERBOSE: [ServerName]: LCM: [ Start Test ] [[Script]SetVirtualDirectoriesDefaults]
2018-06-10T14:47:45.8605246Z VERBOSE: [ServerName]: LCM: [ End Test ] [[Script]SetVirtualDirectoriesDefaults] in 0.0630 seconds.
2018-06-10T14:47:45.8605246Z VERBOSE: [ServerName]: LCM: [ Skip Set ] [[Script]SetVirtualDirectoriesDefaults]
2018-06-10T14:47:45.8605246Z VERBOSE: [ServerName]: LCM: [ End Resource ] [[Script]SetVirtualDirectoriesDefaults]
2018-06-10T14:47:45.8605246Z VERBOSE: [ServerName]: LCM: [ End Set ]
2018-06-10T14:47:45.9386357Z ##[error]The SendConfigurationApply function did not succeed.
+ CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : MI RESULT 1
+ PSComputerName : x.x.x.x
2018-06-10T14:47:45.9386357Z VERBOSE: Operation 'Invoke CimMethod' complete.
2018-06-10T14:47:45.9386357Z VERBOSE: Time taken for configuration job to complete is 116.738 seconds
2018-06-10T14:47:45.9386357Z
This is the configuration's xWebVirtualDirectory section:
xWebVirtualDirectory Vd1
{
Name = 'Vd1'
Website = $Node.WebSiteName
WebApplication = ''
Ensure = 'Absent'
DependsOn = '[xWebsite]Web'
}
xWebVirtualDirectory Vd2
{
Name = 'Vd2'
Website = $Node.WebSiteName
WebApplication = ''
PhysicalPath = "\\ServerName\PathToVD\Vd2"
Ensure = 'Present'
DependsOn = '[xWebsite]Web'
}
xWebVirtualDirectory Vd3
{
Name = 'Vd3'
Website = $Node.WebSiteName
WebApplication = ''
PhysicalPath = "\\ServerName\PathToVD\Vd3"
Ensure = 'Present'
DependsOn = '[xWebsite]Web'
}
xWebVirtualDirectory Vd4
{
Name = 'Vd4'
Website = $Node.WebSiteName
WebApplication = ''
PhysicalPath = "\\ServerName\PathToVD\Vd4"
Ensure = 'Present'
DependsOn = '[xWebsite]Web'
}
xWebVirtualDirectory Vd5
{
Name = 'Vd5'
Website = $Node.WebSiteName
WebApplication = ''
PhysicalPath = "\\ServerName\PathToVD\Vd5"
Ensure = 'Present'
DependsOn = '[xWebsite]Web'
}
xWebVirtualDirectory Vd6
{
Name = 'Vd6'
Website = $Node.WebSiteName
WebApplication = ''
PhysicalPath = "\\ServerName\PathToVD\Vd6"
Ensure = 'Present'
DependsOn = '[xWebsite]Web'
}
xWebVirtualDirectory Vd7
{
Name = 'Vd7'
Website = $Node.WebSiteName
WebApplication = ''
PhysicalPath = "\\ServerName\PathToVD\Vd7"
Ensure = 'Present'
DependsOn = '[xWebsite]Web'
}
xWebVirtualDirectory Vd8
{
Name = 'Vd8'
Website = $Node.WebSiteName
WebApplication = ''
PhysicalPath = "\\ServerName\PathToVD\Vd8"
Ensure = 'Present'
DependsOn = '[xWebsite]Web'
}
Script SetVirtualDirectoriesDefaults
{
DependsOn = "[xWebsite]Web"
TestScript = {
$WebSite = Get-Website -Name $using:Node.WebSiteName
If (($WebSite.virtualDirectoryDefaults.userName -ne "") -and ($WebSite.virtualDirectoryDefaults.password -ne "")) {
return $true
}
else {
return $false
}
}
GetScript = {
# Do Nothing
}
SetScript = {
$WebSiteName = $using:Node.WebSiteName
$WebSitePath = "IIS:\Sites\"+$WebSiteName
$WebSite = Get-Item $WebSitePath
$WebSite.virtualDirectoryDefaults.userName = ******************
$WebSite.virtualDirectoryDefaults.password = ******************
$WebSite | Set-Item
}
}
It must be this command that fails. What happens if yu run that command manually? What error message, or prompt, do you get? It might be that it's missing a -Force?
https://github.com/PowerShell/xWebAdministration/blob/687808bff766cfbe87438c758801ac439d1b99ca/DSCResources/MSFT_xWebVirtualDirectory/MSFT_xWebVirtualDirectory.psm1#L143-L145
Hi johlju,
I think I've found the problem, which is probably related to the fact that the virtual directory is under the website and not under specific application.
When I ran the command with -application "" (empty) it always prompt for an application. Once i've replaced it to -application "/" it worked.
I'll test it soon with DSC and keep you posted.
David.
I hope it works, if it does the documentation should be updated. 🙂
Good news my friend 👍 it worked!
2018-06-11T13:56:52.6672649Z VERBOSE: [ServerName]: LCM: [ Start Resource ] [[xWebVirtualDirectory]Vd1]
2018-06-11T13:56:52.6672649Z VERBOSE: [ServerName]: LCM: [ Start Test ] [[xWebVirtualDirectory]Vd1]
2018-06-11T13:56:52.7610463Z VERBOSE: [ServerName]: LCM: [ End Test ] [[xWebVirtualDirectory]Vd1] in 0.1040 seconds.
2018-06-11T13:56:52.7610463Z VERBOSE: [ServerName]: LCM: [ Start Set ] [[xWebVirtualDirectory]Vd1]
2018-06-11T13:56:52.8391689Z VERBOSE: [ServerName]: [[xWebVirtualDirectory]Vd1] Removing existing Virtual Directory "Vd1".
2018-06-11T13:56:52.9329236Z VERBOSE: [ServerName]: LCM: [ End Set ] [[xWebVirtualDirectory]Vd1] in 0.1770 seconds.
2018-06-11T13:56:52.9329236Z VERBOSE: [ServerName]: LCM: [ End Resource ] [[xWebVirtualDirectory]Vd1]
@Davidsod Awesome! 😃 Would you mind posing the working configuration (only the one resource that failed)? Just for reference
@johlju sorry for the delay, there you go:
xWebVirtualDirectory VD
{
Name = 'VDName'
Website = $Node.WebSiteName
WebApplication = '/'
PhysicalPath = "\\$Node.ServerName\Path"
Ensure = 'Absent'
}
The solution is the '/' instead of '':
WebApplication = '/'
@Davidsod Thank you, that should be documented.
feels like the property shouldn't be required, and should use '/' by default if none is specified. Was very confusing to try to figure out how to add a vDir when I didn't have a WebApplication in the site, ended up finding this issue to realize I need to specify '/'. My 0.02
Hi,
I am experiencing 'interactive mode' faults when running
Remove-WebVirtualDirectory -Filter "string" -Application "string" -Name "string" -Confirm:$false
The error occurs when the virtual directory contains content. When there is no content, the Remove-WebVirtualDirectory call succeeds in non-interactive mode.
An internal call to "Remove-Item" prompts to "remove all items". This prompt cannot be suppressed by setting $ConfirmPreference="None", or by using -Confirm:$false.
This is a critical issue for us as it prevents automated removal of LocalUser virtual directories for use with IIS Management authentication in an FTP site.
@caractacus that is outside the scope of this DSC resource module. Please submit an support case to Microsoft so they can help you resolve your issue.
A workaround would of course be to remove the content before removing the virtual directory.