Make sure to import Posh-Ohai module in PowerShell

While PowerShell version 3 will load the module automatically,
PowerShell version 2 requires you to be more explicit.

This was missing in from 239fa1e3c7. We discovered this in
interactive debugging session with Hounsou Dansou.

Change-Id: I88db408c00b8d880cec08a14086e605e99ff8799
This commit is contained in:
Martin Geisler 2015-05-26 18:14:23 +02:00
parent 239fa1e3c7
commit 2ff8166355
2 changed files with 4 additions and 2 deletions

View File

@ -67,7 +67,8 @@ def system_info(client, with_install=False):
perform_install(client)
if client.is_windows():
powershell_command = 'Get-ComputerConfiguration'
powershell_command = ('Import-Module -Name Posh-Ohai;'
'Get-ComputerConfiguration')
output = client.execute(powershell_command)
unicode_output = "%s" % output
load_clean_json = lambda output: json.loads(get_json(output))

View File

@ -38,7 +38,8 @@ class TestSystemInfo(utils.TestCase):
def test_system_info(self):
self.client.execute.return_value = "{}"
posh_ohai.system_info(self.client)
self.client.execute.assert_called_with("Get-ComputerConfiguration")
self.client.execute.assert_called_with("Import-Module -Name Posh-Ohai;"
"Get-ComputerConfiguration")
def test_system_info_json(self):
self.client.execute.return_value = '{"foo": 123}'