serverspecにてregistryの値の確認をする際に、have_property_valueを使用していますが、valueが複数桁になるとエラーが表示されます。
powershellを1つずつ実行して内容を確認しましたが問題はなさそうです。
この場合どのように対処すればよろしいのでしょうか。もしご存じの方がいらっしゃいましたらご教示頂きたいです。
specファイル
describe windows_registry_key('HKEY_CURRENT_USER\Control Panel\Desktop') do it { should exist } it { should have_property_value('ScreenSaveTimeOut', :type_string, '900') } #スクリーンセーバを無効化 end
結果
2) Windows registry key "HKEY_CURRENT_USER\Control Panel\Desktop" should have property value "ScreenSaveTimeOut", :type_string, "900" On host `localhost' Failure/Error: it { should have_property_value('ScreenSaveTimeOut', :type_string, '900') } #スクリーンセーバを無効化 expected #has_property_value?("ScreenSaveTimeOut", :type_string, "900") to return true, got false $exitCode = 1 $ProgressPreference = "SilentlyContinue" try { $success = $((Compare-Object (Get-Item 'Registry::HKEY_CURRENT_USER\Control Panel\Desktop').GetValue('ScreenSaveTimeOut') @('900')) -eq $null) if ($success -is [Boolean] -and $success) { $exitCode = 0 } } catch { Write-Output $_.Exception.Message } Write-Output "Exiting with code: $exitCode" exit $exitCode Cannot bind argument to parameter 'ReferenceObject' because it is null. Exiting with code: 1
powershell個別実行結果
PS C:\Users\Administrator> Get-Item 'Registry::HKEY_CURRENT_USER\Control Panel\Desktop' Hive: HKEY_CURRENT_USER\Control Panel Name Property ---- -------- Desktop DragHeight : 4 CoolSwitchColumns : 7 ActiveWndTrackTimeout : 0 MouseCornerClipLength : 6 MouseMonitorEscapeSpeed : 0 DragWidth : 4 WallpaperStyle : 10 ScreenSaveActive : 1 TileWallpaper : 0 WheelScrollLines : 3 Pattern : 0 FontSmoothingType : 2 WindowArrangementActive : 1 BlockSendInputResets : 0 MenuShowDelay : 400 ClickLockTime : 1200 CaretWidth : 1 FocusBorderWidth : 1 WallpaperOriginX : 0 WallpaperOriginY : 0 DragFullWindows : 0 CoolSwitchRows : 3 ForegroundFlashCount : 7 LeftOverlapChars : 3 ForegroundLockTimeout : 200000 FontSmoothingGamma : 0 DragFromMaximize : 1 FontSmoothing : 2 FocusBorderHeight : 1 WheelScrollChars : 3 DockMoving : 1 SnapSizing : 1 CursorBlinkRate : 530 MouseWheelRouting : 1 RightOverlapChars : 3 FontSmoothingOrientation : 1 PaintDesktopVersion : 0 Win8DpiScaling : 0 UserPreferencesMask : {144, 18, 3, 128...} Wallpaper : C:\Windows\Web\Wallpaper\Windows\img0.jpg MaxVirtualDesktopDimension : 2560 MaxMonitorDimension : 2560 TranscodedImageCount : 1 LastUpdated : 4294967295 TranscodedImageCache : {122, 195, 1, 0...} LockScreenAutoLockActive : 0 ScreenSaveTimeOut : 900 ScreenSaverIsSecure : 1 PS C:\Users\Administrator>
PS C:\Users\Administrator> $((Compare-Object (Get-Item 'Registry::HKEY_CURRENT_USER\Control Panel\Desktop').GetValue('Sc reenSaveTimeOut') @('900')) -eq $null) True
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。