Powershell script to search specific event ID's from Archive Event files

Hi,
I have to search some Windows Event ID's from Archive event (evtx) files. for that i am trying powershell code mentioned on below link but its not working. Kindly suggest how to search specific event id from archive logs.
http://social.technet.microsoft.com/Forums/windowsserver/en-US/83cbf185-bd96-4efc-b36b-59439024960a/parse-message-property-from-archived-eventlog
Regards,
Dhiraj

Hi,
Thanks for your response. I am using below code & getting below message. I changed the event ID & got some results. Can we remove those lines form results where record not found. like how can we get only those records which match given
event ID. also it's not showing all field values. Is there any formating issue.
$SearchID='4740' 
get-childitem "C:\Windows\System32\Winevt\Logs\Archive-Security*.evtx" | select FullName | forEach{
 %{get-winevent  -filterHashTable @{path=$_.Fullname;ID=$SearchID} |                
    ? {$_.Properties[5].Value -match $UserName} |   
    Select-Object -Property TimeCreated, `
                            @{Name='SecurityId';Expression={$_.Properties[4].Value}}, `
                            @{Name='AccountName';Expression={$_.Properties[5].Value}}, `
                            @{Name='AccountDomain';Expression={$_.Properties[6].Value}}, `
                            @{Name='LogonId';Expression={$_.Properties[7].Value}}, `
                            @{Name='LogonType';Expression={$_.Properties[8].Value}}, `
                            @{Name='Workstation';Expression={$_.Properties[11].Value}}, `
                            @{Name='LogonGuid';Expression={$_.Properties[12].Value}} |
    Format-Table
Get-WinEvent : No events were found that match the specified selection criteria.
At C:\Users\sidadmin1\Documents\EventIDCheck.ps1:3 char:16
+  %{get-winevent <<<<   -filterHashTable @{path=$_.Fullname;ID=$SearchID} |
    + CategoryInfo          : ObjectNotFound: (:) [Get-WinEvent], Exception
    + FullyQualifiedErrorId : NoMatchingEventsFound,Microsoft.PowerShell.Commands.GetWinEventCommand
TimeCreated    SecurityId     AccountName     AccountDomain LogonId        LogonType      Workstation    LogonGuid
3/11/2014 4... DC04$          MyDomain                 999
Get-WinEvent : No events were found that match the specified selection criteria.
At C:\Users\sidadmin1\Documents\EventIDCheck.ps1:3 char:16
+  %{get-winevent <<<<   -filterHashTable @{path=$_.Fullname;ID=$SearchID} |
    + CategoryInfo          : ObjectNotFound: (:) [Get-WinEvent], Exception
    + FullyQualifiedErrorId : NoMatchingEventsFound,Microsoft.PowerShell.Commands.GetWinEventCommand
Dhiraj

Similar Messages

  • Exchange PowerShell script to get mailbox properties of user from a CSV file

    Hi Team,
    I've a CSV file with alias of numerous users and I want to get their mailbox sizes and other properties. These users are dispersed in various databases of same Exchange organization.
    Need a Powershell Script, Any help?
    Muhammad Nadeem Ahmed Sr System Support Engineer Premier Systems (Pvt) Ltd T. +9221-2429051 Ext-226 F. +9221-2428777 M. +92300-8262627 Web. www.premier.com.pk

    You can use this and modify it to what you need. Output to a file (IE: Export-CSV "path to file"
    If you need more specifics let me know. This one is for one user at a time but can be used to read a CSV file.
    # Notifies the user a remote session needs to be started
    Write-Host "Get a users mailbox size" -fore yellow -back red;
    Write-Host "Please wait while a remote session started" -fore red -back yellow;
    # Import a remote session with exchange
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://exchangeservername/Powershell/ -Authentication Kerberos
    Import-PSSession $Session
    Do {
    # Prompts user for a name
    $name = Read-Host "Enter a username"
    # Get the mailbox statistics for that user
    Get-MailboxStatistics $name | fl totalitemsize, storagelimitstatus, totaldeleteditemsize | out-default
    # Give the user a choice to test another or EXIT
    $Output = Read-Host "Press Y to continue or ENTER to exit"
    # Ends the program if the user does not press Y
    Until ($Output -ne "Y")
    HossFly, Exchange Administrator

  • Powershell script to get the domain admin list from non domian member server

    hello Script guys!
    I am new of the powershell scripting.
    currently I am working on autometion project , we would like generate a privilege report for our existing servers.
    in our environment, there are many seprated domain , we would like generate the report from one server instead to login each server to check , could you provide some guide on how can we get the specific domain admin list for each domain from a non domain
    membership server by using the powershell script? many thanks for your help.

    You could remote to the domain controller or use ADSI to query the domain.
    Look inth eGallery as ther eare many scripts there tha will return group membership using ADSI.
    ¯\_(ツ)_/¯

  • Is there a way to create a multiple event screen saver from iPhoto events?

    Is there a way to create a multiple event screen saver from photos in iphoto?  I can create a single event screen saver, but don't know if it is possible to create a screen saver with more than one event.

    Drag the events you want into an album and have the screen saver run from the album.

  • HT2479 I recently updated the iMovie app and now all my events are missing from the event library, although they seem to be on the external hard drive...how do I restore all the clips (I have begun to edit the clips down) I am a recent PC convert, thanks

    I just updated the imovie app and all the clips from the event library are now missing, although they seem to be on the external hard drive...I am a new mac user, so please help...thanks...

    I just updated the imovie app and all the clips from the event library are now missing, although they seem to be on the external hard drive...I am a new mac user, so please help...thanks...

  • Powershell script to search a network drive for .mdb files and export them to CSV file

    Hello all,
    I'm trying to search one of our network drives for old .mdb files, I want to write the name, location and date last modified to a csv file.
    Get-WmiObject -Class CIM_DataFile -Filter "Drive='S:' And Extension='mdb'
     AND ObjFile.drive
     AND objFile.FileName
     AND objFile.FileSize
     AND objFile.LastWriteTime" |
    Export-CSV c:\mdb_search\mdbfiles.csv\
    Obviously this isn't working or I wouldn't be posting.  I've tried many different examples from the net with no joy for now.
    Thanks for any help you can offer.

    Thanks, that did the job.
    Cheers, you're welcome.
    How do I get the powershell cursor to return to C:> ?
    Should I use "exit" or "break" ?
    Neither, the console will return to a prompt when the search has been completed.
    Don't retire TechNet! -
    (Don't give up yet - 13,225+ strong and growing)

  • Howto create a powershell script to search the C drive for any *.pst files and copy them to a single directory

    I have a bunch of people who are saving their pst files all over the place. how do I write a script that does the following
    searches the C:\ drive for *.pst and copies them all the E:\pstfiles

    Hi,
    How about using below command:
    Move-Item c:\*.pst E:\pstfiles -force
    For more details about move-item, I would like suggest you use get-help command:
    get-help move-item
    In addition:
    Using the Move-Item Cmdlet
    http://technet.microsoft.com/en-us/library/ee176910.aspx
    Regards,
    Yan Li
    Yan Li
    TechNet Community Support

  • I want to write a powershell script to clear specific printer queues from csv

    This is what I have so far, but doesn't seem to be working. Any help would be appreciated.
    $InCSVPath = "c:\printeraddscript\printerremove.csv"
    $csv = Import-Csv $InCSVPath
    foreach($item in $csv){     
           $server = $item.Server + ".Domain name here"  
           $printer = $item.Printer  
           $a = Get-WmiObject Win32_PrintJob -ComputerName $server -Filter "Name='$printer'" }
    foreach ($job in $a)
       "Canceling job $($job.JobId)"   

    Import-Csv c:\printeraddscript\printerremove.csv |
    ForEach-Object{
    Get-WmiObject Win32_Printer -ComputerName $_.server -Filter "Name='$($_.printer)'" } |
    ForEach-Object{
    $_.CancelAllJobs()
    ¯\_(ツ)_/¯

  • PowerShell script to find and remove duplicate items from document library

    Hi Friends,
    Please check this below script, It is finding the duplicate items and removing it. This script is not working to find the duplicate items from document
    library and remove. Can you please let me know where it is wrong.
    Add-PSSnapin microsoft.sharepoint.powershell 
    $web = Get-SPWeb -Identity "http://zapltvsspdev02:4333/bu/EXCO" 
    $list = $web.Lists["AECI Documents"] 
    $AllDuplicates = $list.Items.GetDataTable() | Group-Object INumber | where {$_.count -gt 1} 
    $count = 1 
    $max = $AllDuplicates.Count 
    foreach($duplicate in $AllDuplicates) 
    $duplicate.group | Select-Object -Skip 1 | % {$list.GetItemById($_.ID).Delete()} 
    Write-Progress -PercentComplete ($count / $max * 100) -Activity "$count duplicates removed" -Status "In Progress" 
    $count++ 
    Remove-PsSnapin Microsoft.SharePoint.PowerShell
    Note:
    In the above code, duplicates are found using the "INumber" column. 
    valmiki

    check this
    http://stackoverflow.com/questions/21337158/delete-duplicate-items-in-sharepoint-list

  • Script that gives specific names to layers - from bottom to the top

    Hi,
    This is probably an easy one for anyone with JavaScript experience.
    I have 35 layers that I want to give specific names to (now they're named liked "layer 1, 2, 3" - but sometimes this won't be consistent, so some numbering might be skipped,
    in other words I can't rely on a script that renames a specific "Layer 1" to "my name").
    I want to rename each layer from the bottom to the top, i.e.:
    "Power"
    "Yellow"
    "Hello"
    With the script working its way up from the bottom to the top.
    How do I accomplish this?
    Thank you so much for you taking your time to help me.

    something like this?
    if so, type your names in a text frame, select it and run this script
    // rename Layers from the bottom up
    // carlos canto
    // https://forums.adobe.com/thread/1653162
    // type your names in a text frame, select it and run this script
    var idoc = app.activeDocument;
    var itext = idoc.selection[0];
    var a_names = itext.contents.split ('\r').reverse();
    var namecount = a_names.length;
    var layercount = idoc.layers.length;
    var counter = Math.min(namecount, layercount);
    for (i=layercount-1, j=0; i>=layercount-counter; i--, j++) {
        var ilayer = idoc.layers[i];
        ilayer.name = a_names[j];

  • A real task..( to search and display few lines from a log file)

    have a look at the following link
    http://computing.unn.ac.uk/staff/cgpb2/public_html/log.html
    i need to display to the users only the Hourly Transmission Statistics (Bytes Sent Requests Time) on a tabular format from the above mentioned link.
    t
    his is not easy
    can any one write down the code please..
    thank you very much.

    What have you done so far?
    What kind of approach are you going to take (aside from asking others to do it all for you)?
    Have you written the algorithm in psuedo-code? If so, can we see it? We might be able to give you a few pointers.

  • Executing SCVMM PowerShell scripts via C# conditionally works depending on application type

    I suspect that this is the wrong forum but I could not find one that was appropriate.
    The environment is SCVMM 2012 R2. I have a series of PowerShell scripts that are executed via C# code from a variety of applications -- MVC, WCF, console, unit tests. It seems that successful connection to the VMM server is dependent on the type of application
    being used. For example, console apps and WCF apps can connect successfully but the
    same code running in a unit test or standard MVC app throw the following exception:
    {You cannot access VMM management server SC-01. (Error ID: 1604)
    Contact the Virtual Machine Manager administrator to verify that your account is a member of a valid user role and then try the operation again.}
        CategoryInfo: {ReadError: (:) [Get-SCVirtualMachine], CarmineException}
        ErrorDetails: {You cannot access VMM management server SC-01. (Error ID: 1604)
    Contact the Virtual Machine Manager administrator to verify that your account is a member of a valid user role and then try the operation again.}
        Exception: {"You cannot access VMM management server SC-01.\r\nContact the Virtual Machine Manager administrator to verify that your account is a member of a valid user role and then try the operation again."}
        FullyQualifiedErrorId: "1604,Microsoft.SystemCenter.VirtualMachineManager.Cmdlets.GetVMCmdlet"
        InvocationInfo: Command = {Get-SCVirtualMachine}
        PipelineIterationInfo: Count = 0
        ScriptStackTrace: "at <ScriptBlock>, <No file>: line 1"
        TargetObject: null
    I suspect that somehow, each app is running under different credentials but I cannot see how that is possible. Each app exhibits the stated behavior whether running within Visual Studio (w/ IIS Express) [running under my own account] or published to the
    server running under a specific specified account that definitely has permissions to the VMM environment.
    This behavior is easily reproducible with the following code
    -- PS Script as embedded resource
    Get-SCVirtualMachine -VMMServer "SC-01"
    -- C# code to load and execute script
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Management.Automation;
    namespace LabManagement {
    public class HyperVVirtualMachineManager {
    public IEnumerable<Models.VirtualMachine> GetVirtualMachines() {
    var vms = new List<Models.VirtualMachine>();
    try {
    using (var rs = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace()) {
    rs.Open();
    using (var ps = PowerShell.Create()) {
    ps.Runspace = rs;
    var assembly = System.Reflection.Assembly.GetExecutingAssembly();
    var scriptName = "LabManagement.Scripts.GetAllVirtualMachines.ps1";
    using (var s = assembly.GetManifestResourceStream(scriptName)) {
    using (var reader = new System.IO.StreamReader(s)) {
    var script = reader.ReadToEnd();
    ps.AddScript(script);
    var output = ps.Invoke();
    if (ps.Streams.Error.Count > 0) {
    foreach (var item in ps.Streams.Error) {
    // do something
    if (output.Count > 0) {
    foreach (var o in output) {
    // do something
    rs.Close();
    catch (RuntimeException ex) {
    // do something
    return vms;
    -- Console app (Success)
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace VirtualLabManagement.ConsoleTests {
    class Program {
    static void Main(string[] args) {
    // Arrange
    var svc = new LabManagement.HyperVVirtualMachineManager();
    // Act
    var hosts = svc.GetVirtualMachines();
    // Assert
    -- Unit Test (Fails)
    [TestMethod]
    public void TestMethod1() {
    // Arrange
    var svc = new LabManagement.HyperVVirtualMachineManager();
    // Act
    var hosts = svc.GetVirtualMachines();
    // Assert
    Assert.IsNull(hosts);
    As you can see, the code is exactly the same between the different executions but the ability to connect differs.

    Hi Sir,
    I would like to check the following items:
    1. "a variety of applications -- MVC, WCF, console, unit tests." they are all installed on same computer?
    2. VMM server still installed on same computer as these app resides in ?
    (if it is possible please detail the topology of the environment )
    If they are running at same account on same computer , I would suggest you to post this issue into Code UI forum for further assistance :
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vstest
    Best Regards,
    Elton JI
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] .

  • How to copy a folder from TFS source control to Shared location with Powershell script

    Hi,
    I'm looking for a Powershell script where i could copy a folder from TFS Source control to a shared location.
    Details:
    $TeamProject/FolderA - here i want to move FolderA to a shared location called \\Share
    Tried with xcopy: xcopy "$TeamProject/FolderA" "\\Share" ( but no luck, later i found it's only possible to copy files from local to share or share to share location, not from server path to shared location.
    Can someone help me with the power-shell script to achieve above scenario.
    Thanks, BHSR

    Hope the below script works for your scenario. Got the code from http://stackoverflow.com/questions/23739499/copy-files-from-tfs-versioncontrol-to-directory-with-powershell
    $AutoDeployDir = "$\TeamProject/FolderA"
    $deployDirectory = "\\SERVER\SHAREFOLDER\"
    # Add TFS 2013 dlls so we can download some files
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Client")
    $tfsCollectionUrl = "http://CDTFSSERVER:8080/tfs/ProjectCollection"
    $tfsCollection = New-Object -TypeName Microsoft.TeamFoundation.Client.TfsTeamProjectCollection -ArgumentList $tfsCollectionUrl
    $tfsVersionControl = $tfsCollection.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
    # Register PowerShell commands
    Add-PSSnapin Microsoft.TeamFoundation.PowerShell
    # Get all directories and files in the AutoDeploy directory
    $items = Get-TfsChildItem $AutoDeployDir -Recurse -Server $tfsCollection
    # Download each item to a specific destination
    foreach ($item in $items) {
    # Serverpath of the item
    Write-Host "TFS item to download:" $($item.ServerItem) -ForegroundColor Blue
    $destinationPath = $item.ServerItem.Replace($AutoDeployDir, $deployDirectory)
    Write-Host "Download to" $([IO.Path]::GetFullPath($destinationPath)) -ForegroundColor Blue
    if ($item.ItemType -eq "Folder") {
    New-Item $([IO.Path]::GetFullPath($destinationPath)) -ItemType Directory -Force
    else {
    # Download the file (not folder) to destination directory
    $tfsVersionControl.DownloadFile($item.ServerItem, $([IO.Path]::GetFullPath($destinationPath)))
    Regards, Bharath
    LinkedIn:

  • Powershell script - how to read a registry hive and store the value in text file and then again read the text file to write the values back in registry

    Hi All,
    powershell script Method required to read a value from registry and then taking the backup of that values in some text file.
    For example the hive is
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path
    and under path i need to take back up  of values in some text file and then put some value in the registry after back is taken in text file.
    Also how to read the text file values so that we can again write to registry hive  back from the back up text file.
    Your help is much appreciated.
    Umeed4u

    I think you need to read this first:
    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/a0def745-4831-4de0-a040-63b63e7be7ae/posting-guidelines?forum=ITCG
    Don't retire TechNet! -
    (Don't give up yet - 12,830+ strong and growing)

  • Executing powershell scripts via Task Scheduler

    Hi,
    I have a powershell script that I wrote that when executed from the shell works fine but when executed from task scheduler does not work.
    In my script, an email is sent out based on the results of the execution.  When I run this from the shell, email goes out, when scheduled, no email and there is no indication of errors having occurred anywhere in the system.
    Has anyone run into a similar issue?
    I did change my powershell execution policy to be unrestricted (both in the x86 and x64 consoles).  I am running Windows 2008 R2.
    Thanks - Greg.

    Hi,
    In addition the above suggestions, please also refer to the below threads:
    Using Task Scheduler for a powershell script on server 2008
    http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/e298d613-47b8-4492-92d1-0b55cc8497c1
     Using Windows Task Scheduler to execute Powershell Script frequently
    http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/5901a6ad-ba18-4817-82a9-f75d2d6b439f
    Hope this helps.
    Best Regards,
    Yan Li
    Yan Li
    TechNet Community Support

Maybe you are looking for

  • Running Netscape 7 from CDE.

    I have been running Solaris 9 x86. Clicking the Front Panel Clock Control in CDE would open Netscape 4. I installed the following Netscape 7 package. bash-2.05$ pkginfo -l SUNWnsb PKGINST: SUNWnsb NAME: Netscape 7 for Solaris - Browser CATEGORY: appl

  • Can anyone help - LR5.3 won't start after only 2 successful days!!

    2 days ago installed LR5.3 trial on my new PC bought to run LR and CS6 - Win 7 Pro, Xeon E3-1230, 32gb memory, SSDs etc (the works). Worked great for 2 days, cataloging a big trip, lots of adjustments made. Yesterday I found LR had unexplained errors

  • Convert non batch managed material to batch managed

    What are the prerequisites to convert a non batch managed material to a batch managed one?

  • Text from CC behaves incorrect in CC 2014

    Hi Everybody, Currently I came across strange behaviour of the text created in CC but opened in CC 2014. Figure A shows how text looked like in CC also it shows how it looks like in CC 2014 in key line mode. Figure B shows how text looks like in CC 2

  • Deployment descriptor configuration tool

    Hi, My company delivers a weblogic server based product. We have the following problem: when we deliver a new version of the product (basically, a new .ear), we overwrite the previous deployment descriptor of each EJB, Connector, etc... This means th