How to get PST file onwer from network location using powershell

This topic contains 2 replies, has 2 voices, and was last updated by  Ajay 7 months, 2 weeks ago.

  • Author
  • #81556


    How to PST file owner,Filename,network location path,size of the PST file.

  • #81562


    This why the Get-ChildItem Get-Acl cmdlets exists.
    Get-ChildItem -Path [Path to file location]
    Get-Acl $Path | Select Path, Owner -expand access

    # Quick and dirty.
    ($FilesToVerify = Get-ChildItem -Path C:\Temp -Filter '*.pst' | Select -Property PSDrive,Fullname,Length -First 1 )
    ForEach($TargetFile in $FilesToVerify)
    {Get-Acl $TargetFile.FullName | Select Owner -expand access}

    I am not sure what you mean by network location, because you have to know where the file is to ask for any info on it.
    There is no network location as meta data on a file. Which means you already have to know the network location / servername / clientname.
    This is domain level information / client / server, not network IP ranges.
    If you are saying, you want to pull the server's IPA from the server name from which you asked for file information, then that is
    what Test-Connection is for.

    So, changing the above a bit, you get...
    # Test if the server target that has the file(s) needed is up
    ($ServerIPA = (Test-Connection -ComputerName 'satlws01' -Count 1)).IPV4Address
    # You could use that IPA to determine what network segment the server was in, but why is the question.

    ($FilesToVerify = Get-ChildItem -Path C:\Temp -Filter '*.pst' | Select -Property PSDrive,Fullname,Length -First 1 )
    ForEach($TargetFile in $FilesToVerify)
    {Get-Acl $TargetFile.FullName | Select Owner -expand access}

    # Now, none of the above is elegant, and can be made better, but this should get you started.

  • #81568


    Thanks for your quick response. Below listed is my requirement...
    Data fetch of PST File path location in client machines.
    I already have a script file which is able to fetch the details like Path, Size, last login user of PST file path from client systems.
    But i also want to know the PST file owner from whose ID/maibox it has been created...could you please help on the same.

    Below is the script which i am currently using to fetch the details which is not giving the PST file owner details:
    $strComputers = Get-Content -Path "C:\Computers.txt"
    [bool]$firstOutput = $true
    foreach($strComputer in $strComputers)
    $colFiles = Get-Wmiobject -namespace "root\CIMV2" `
    -computername $strComputer `
    -Query "Select * from CIM_DataFile `
    Where Extension = 'pst'"
    foreach ($objFile in $colFiles)
    if($objFile.FileName -ne $null)
    $filepath = $objFile.Drive + $objFile.Path + $objFile.FileName + "." `
    + $objFile.Extension;
    $query = "ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" `
    + $filepath `
    + "'} WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner"

    $LogedInUser = Get-WmiObject -ComputerName $strComputer -Class Win32_ComputerSystem -Property UserName |
    Select-Object -Property UserName
    $output = $strComputer + "," + $filepath + "," + $user + "," + $objFile.FileSize/1gb + "," + $LogedInUser
    Write-output $output | Out-File -Encoding ascii -filepath "C:\Result.csv"
    $firstOutput = $false
    Write-output $output | Out-File -Encoding ascii -filepath "C:\Result.csv" -append

You must be logged in to reply to this topic.