Limit-EventLog -LogName Security -ComputerName "Server01", "Server02" -RetentionDays 7This command ensures that events in the Security log on the Server01 and Server02 computers are retained for at least 7 days.Example 3: Change the overflow action of all event logsPowerShell Copy ...
{$_.EventID-eq63} |Select-Object-PropertySource, EventID, InstanceId, Message Source EventID InstanceId Message --- --- --- --- Outlook631073741887The Exchange web service request succeeded. Outlook631073741887Outlook detected a change notification. Outlook631073741887The Exchange web service request...
The Get-WinEvent cmdlet uses the ListLog parameter to specify the Security log. The object is saved to a variable. The MaximumSizeInBytes property is set to 1 gigabyte on the object. The SaveChanges method is called to push the change to the system inside of a tr...
If the log folder does not exist on the remote computer, we use the New-Item cmdlet to create it. We have a hard-coded value of LogFolder, but you can change this. As in the previous New-Item cmdlet, we use the -force parameter to create the entire path and pipeline the results ...
This script will run the powershell.exe executable, not sqlps.exe. If the server where this job is to run is running SQL Server 2008 you can change the JobStep’s SubSystem property to ‘PowerShell’, and the Command property to ‘e:\scripts\backup.ps1’. The job is created by using...
# Change the ErrorActionPreference to 'Continue' $ErrorActionPreference = 'Continue' # Generate a non-terminating error and continue processing the script. Write-Error -Message 'Test Error' ; Write-Host 'Hello World' Output 复制 Write-Error: Test Error Hello World 此示例显示$ErrorActionPreferen...
You can very easily change the date value, and you can pipe the output to the Resolve-Alert cmdlet.Test Alerts Sometimes you want to be able to monitor certain events in the Windows Event Viewer and test for them. These two lines will create a quick event log entry:...
New-EventLog Creates a new event log and a new event source on a local or remote computer. New-Item Creates a new item. New-ItemProperty Creates a new property for an item and sets its value. For example, you can use New-ItemProperty to create and change registry values and data, whic...
Important! Selecting a language below will dynamically change the complete page content to that language. Select language English Download Expand all|Collapse all Version: 1 Date Published: 4/23/2014 File Name: PowerShell_Examples_v4.pdf
'Boot Device','System Locale','Input Locale','Time Zone','Total Physical Memory','Available Physical Memory','Virtual Memory: Max Size','Virtual Memory: Available','Virtual Memory: In Use','Page File Location(s)','Domain','Logon Server','Hotfix(s)','Network Card(s)'FunctionF_Sys...