Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Assistance with retrieving File and Version on a file with "custom file properties"

$
0
0

Morning,

I am attempting to get the file version and date info from a file on multiple workstations on our network. I already know the file location, name and even which workstations the file is on. What I cannot get the script to do is query them and return the file version/date info. I need this so that I can identify which workstations require an update.

Here is what we have written so far, but it errors out with "there is not a "in" for the "for each" statement. The "in" is there so I am missing something else that I just cannot see. I need to feed the workstation names to the script and get the results out put to a csv file.

$application = New-Object -ComObject excel.application 
$application.Visible = $false 
$document = $application.workbooks.open("C:\Program Files\Common Files\SAP Shared\BW\sapbex.xla") 
$binding = "System.Reflection.BindingFlags" -as [type] 
$customProperties = $document.CustomDocumentProperties 
foreach ($Property in $customProperties) 
{  $pn = [System.__ComObject].InvokeMember("name",$binding::GetProperty,$null,$property,$null)   trap [system.exception]    {      write-host -foreground blue "Value not found for $pn"     continue    }   "$pn`: " +    [System.__ComObject].InvokeMember("value",$binding::GetProperty,$null,$property,$null)  
} 
$application.quit()

Thanks in advance for your time and assistance.

T.S.



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>