Hi Guys,
i’m getting crazy about this setup.
Maybe you got an idea.
I’m connecting to our Exchange/Windows servers by winrm with the domain admin user. This is working.
Running a role with the task
`
- name: Testname
win_command: ipconfig /all
`
this is also working.
But i need to use winrm to execute a commad (cmdlet) inside the Exchange Management Shell…
So i tried to upload a script.ps1 to my %HOMEPATH% for the domain admin and tried to run this script there - not working, script is not found for example when i’m using full paths like c:\users\administrator.DOMAIN
So i switched back to simple names without any paths and then i got everything under my current domain admin users folder c:\users\administrator.DOMAIN\ …ok.
I uploaded a powershell script like
`
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -version 2.0 -NonInteractive -command “. ‘C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto; Get-Mailbox”
`
This is what’s inside the role/tasks/main.yml
`
-
win_file: path=ansible state=directory
-
win_copy: src=script.ps1 dest=script.ps1 force=yes
-
name: Get information about a user
script: script.ps1
register: output -
debug: msg={{output}}
`
When running the task above i get
`
ok: [my_windows_host] => {
“msg”: {
“changed”: true,
“rc”: 0,
“stderr”: “TryLoadExchangeTypes : Exception calling "TryLoadExchangeTypes" with "2" argument(s): "Exception of type ‘System.OutOfM\r\nemoryException’ was thrown."\r\nAt C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1:75 char:92\r\n+ $typeLoadResult = [Microsoft.Exchange.Configuration.Tasks.TaskHelper]::TryLoadExchangeTypes <<<< ($ManagementPath, $t\r\nypeListToCheck)\r\n + CategoryInfo : NotSpecified: ( , MethodInvocationException\r\n + FullyQualifiedErrorId : DotNetMethodException\r\n \r\nRegisterAssemblyResolver : Exception calling "RegisterAssemblyResolver" with "0" argument(s): "The type initializer for\r\n ‘Microsoft.Exchange.Data.SerializationTypeConverter’ threw an exception."\r\nAt C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1:87 char:79\r\n+ [Microsoft.Exchange.Data.SerializationTypeConverter]::RegisterAssemblyResolver <<<< ()\r\n + CategoryInfo : NotSpecified: ( , MethodInvocationException\r\n + FullyQualifiedErrorId : DotNetMethodException\r\n \r\nUpdate-TypeData : \r\nAt C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1:104 char:16\r\n+ Update-TypeData <<<< -PrependPath $partialTypeFile \r\n + CategoryInfo : InvalidOperation: ( [Update-TypeData], RuntimeException\r\n + FullyQualifiedErrorId : TypesXmlUpdateException,Microsoft.PowerShell.Commands.UpdateTypeDataCommand\r\n \r\nwrite-host : \r\nAt C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1:170 char:16\r\n+ write-host -no <<<< $RemoteExchange_LocalizedStrings.res_full_list\r\n + CategoryInfo : WriteError: ( [Write-Host], ParameterBindingException\r\n + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.WriteHostCommand\r\n \r\nwrite-host : \r\nAt C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1:171 char:16\r\n+ write-host -no <<<< " "\r\n + CategoryInfo : WriteError: ( [Write-Host], ParameterBindingException\r\n + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.WriteHostCommand\r\n \r\nwrite-host : \r\nAt C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1:174 char:16\r\n+ write-host -no <<<< $RemoteExchange_LocalizedStrings.res_only_exchange_cmdlets\r\n + CategoryInfo : WriteError: ( [Write-Host], ParameterBindingException\r\n + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.WriteHostCommand\r\n \r\nwrite-host : \r\nAt C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1:175 char:16\r\n+ write-host -no <<<< " "\r\n + CategoryInfo : WriteError: ( [Write-Host], ParameterBindingException\r\n + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.WriteHostCommand\r\n \r\nwrite-host : \r\nAt C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1:178 char:16\r\n+ write-host -no <<<< $RemoteExchange_LocalizedStrings.res_cmdlets_specific_role\r\n + CategoryInfo : WriteError: ( [Write-Host], ParameterBindingException\r\n + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.WriteHostCommand\r\n \r\n”,
“stdout”: “The Exchange types file wasn’t loaded because not all of the required files could be found.\n\n Welcome to the Exchange Management Shell!\n\nGet-Command\nGet-ExCommand\n”,
“stdout_lines”: [
“The Exchange types file wasn’t loaded because not all of the required files could be found.”,
“”,
" Welcome to the Exchange Management Shell!",
“”,
“Get-Command”,
“Get-ExCommand”
]
}
}
`
I don’t get it why the
; Get-Mailbox
part is not executed from my script, but anything else before, what is wrong?
Is this OutOfMemory Exception because of https://support.microsoft.com/de-de/kb/2842230 ?
Any (other) ideas?
Thx
Cheers
Christian