From 2ff8166355b6832040f8de08782464da8ebce506 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Tue, 26 May 2015 18:14:23 +0200 Subject: [PATCH] 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 239fa1e3c7aa. We discovered this in interactive debugging session with Hounsou Dansou. Change-Id: I88db408c00b8d880cec08a14086e605e99ff8799 --- satori/sysinfo/posh_ohai.py | 3 ++- satori/tests/test_sysinfo_posh_ohai.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/satori/sysinfo/posh_ohai.py b/satori/sysinfo/posh_ohai.py index 2d06777..06ebc76 100644 --- a/satori/sysinfo/posh_ohai.py +++ b/satori/sysinfo/posh_ohai.py @@ -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)) diff --git a/satori/tests/test_sysinfo_posh_ohai.py b/satori/tests/test_sysinfo_posh_ohai.py index d5a4cd3..f3b0d26 100644 --- a/satori/tests/test_sysinfo_posh_ohai.py +++ b/satori/tests/test_sysinfo_posh_ohai.py @@ -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}'