2016-03-18 23:14:56 +01:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2016-08-12 10:19:35 +02:00
|
|
|
unless os.windows?
|
|
|
|
STDERR.puts "\033[1;33mTODO: Not running #{__FILE__} because we are not on Windows.\033[0m"
|
|
|
|
return
|
|
|
|
end
|
2016-05-10 19:23:11 +02:00
|
|
|
|
2016-06-18 17:54:04 +02:00
|
|
|
# Get-WmiObject win32_service or Get-WmiObject -class win32_service
|
2016-03-18 23:14:56 +01:00
|
|
|
# returns an array of service objects
|
2016-06-18 17:54:04 +02:00
|
|
|
describe wmi({class: 'win32_service'}) do
|
2016-03-18 23:14:56 +01:00
|
|
|
its('DisplayName') { should include 'Windows Remote Management (WS-Management)'}
|
|
|
|
end
|
|
|
|
|
2016-06-18 17:54:04 +02:00
|
|
|
# Use win32_service with filter, it returns a single service object
|
|
|
|
describe wmi({
|
|
|
|
class: 'win32_service',
|
2016-03-18 23:14:56 +01:00
|
|
|
filter: "name like '%winrm%'"
|
|
|
|
}) do
|
2016-06-18 17:54:04 +02:00
|
|
|
its('Status') { should cmp 'ok' }
|
|
|
|
its('State') { should cmp 'Running' }
|
|
|
|
its('ExitCode') { should cmp 0 }
|
2016-03-18 23:14:56 +01:00
|
|
|
its('DisplayName') { should eq 'Windows Remote Management (WS-Management)'}
|
|
|
|
end
|
|
|
|
|
|
|
|
# TODO: this works on domain controllers only
|
2016-06-18 17:54:04 +02:00
|
|
|
describe wmi({
|
|
|
|
class: 'RSOP_SecuritySettingNumeric',
|
|
|
|
namespace: 'root\\rsop\\computer',
|
|
|
|
filter: 'KeyName = \'MinimumPasswordAge\' And precedence=1'
|
|
|
|
}) do
|
|
|
|
its('Setting') { should eq 1 }
|
|
|
|
end
|
|
|
|
|
|
|
|
# new syntax
|
|
|
|
describe wmi({
|
|
|
|
namespace: 'root\rsop\computer',
|
|
|
|
query: "SELECT Setting FROM RSOP_SecuritySettingBoolean WHERE KeyName='LSAAnonymousNameLookup' AND Precedence=1"
|
|
|
|
}) do
|
|
|
|
its('Setting') { should eq false }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe wmi({
|
|
|
|
namespace: 'root\cimv2',
|
|
|
|
query: 'SELECT filesystem FROM win32_logicaldisk WHERE drivetype=3'
|
|
|
|
}).params.values.join do
|
|
|
|
it { should eq 'NTFS' }
|
|
|
|
end
|
|
|
|
|
|
|
|
# deprecated syntax
|
|
|
|
describe wmi('win32_service') do
|
|
|
|
its('DisplayName') { should include 'Windows Remote Management (WS-Management)'}
|
|
|
|
end
|
|
|
|
|
2016-03-18 23:14:56 +01:00
|
|
|
describe wmi('RSOP_SecuritySettingNumeric', {
|
|
|
|
namespace: 'root\\rsop\\computer',
|
|
|
|
filter: 'KeyName = \'MinimumPasswordAge\' And precedence=1'
|
|
|
|
}) do
|
|
|
|
its('Setting') { should eq 1 }
|
2016-06-18 17:54:04 +02:00
|
|
|
its('setting') { should eq 1 }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe wmi('win32_service', {
|
|
|
|
filter: "name like '%winrm%'"
|
|
|
|
}) do
|
|
|
|
its('DisplayName') { should eq 'Windows Remote Management (WS-Management)'}
|
2016-03-18 23:14:56 +01:00
|
|
|
end
|