Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
Remove-EventLog.Tests.ps135 linesDownload Raw Back to Microsoft.PowerShell.Management
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3Describe "New-EventLog cmdlet tests" -Tags @('CI', 'RequireAdminOnWindows') {4 5    BeforeAll {6        $defaultParamValues = $PSDefaultParameterValues.Clone()7        $IsNotSkipped = ($IsWindows -and !$IsCoreCLR)8        $PSDefaultParameterValues["it:skip"] = !$IsNotSkipped9    }10 11    AfterAll {12        $global:PSDefaultParameterValues = $defaultParamValues13    }14 15    BeforeEach {16        if ($IsNotSkipped) {17            Remove-EventLog -LogName TestLog -ErrorAction Ignore18            {New-EventLog -LogName TestLog -Source TestSource -ErrorAction Stop}                              | Should -Not -Throw19            {Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 1 -ErrorAction Stop} | Should -Not -Throw20        }21    }22    #CmdLet is NYI - change to -Skip:($NonWinAdmin) when implemented23    It "should be able to Remove-EventLog -LogName <string> -ComputerName <string>" -Pending:($true) {24      { Remove-EventLog -LogName TestLog -ComputerName $env:COMPUTERNAME -ErrorAction Stop }              | Should -Not -Throw25      { Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 1 -ErrorAction Stop } | Should -Throw -ErrorId "Microsoft.PowerShell.Commands.WriteEventLogCommand"26      { Get-EventLog -LogName TestLog -ErrorAction Stop } | Should -Throw -ErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"27    }28    #CmdLet is NYI - change to -Skip:($NonWinAdmin) when implemented29    It "should be able to Remove-EventLog -Source <string> -ComputerName <string>"  -Pending:($true) {30      {Remove-EventLog -Source TestSource -ComputerName $env:COMPUTERNAME -ErrorAction Stop} | Should -Not -Throw31      { Write-EventLog -LogName TestLog -Source TestSource -Message "Test" -EventId 1 -ErrorAction Stop } | Should -Throw -ErrorId "Microsoft.PowerShell.Commands.WriteEventLogCommand"32      { Get-EventLog -LogName TestLog -ErrorAction Stop; } | Should -Throw -ErrorId "System.InvalidOperationException,Microsoft.PowerShell.Commands.GetEventLogCommand"33    }34}35