locked
PowerShell - Need to output filename and company name RRS feed

  • Question

  • Hi

    I've looked into get-ChildItem and Get-Item but can get neither to output the company name which would be handy for me later on. This is to help me just double check dll files which just belong to the company I work for.

    Ideally, can anyone advise me the next step in working this out. I've googled and looked that the member of these two commands but still not sure how to progress :-

    Get-ChildItem | Get-Member


    • Edited by jmatty2000 Tuesday, May 13, 2014 12:35 PM
    Tuesday, May 13, 2014 12:32 PM

Answers

  • jmatty  - you are asking a question that shows you do not understand the difference between an object and a command.  Help only works for commands.  Objects must be inspected with Get-Member.

    Go back and spend time with a full training in PowerShell.  A couple of youtube videos will not be enough.  I recommend starting with a book.


    ¯\_(ツ)_/¯

    • Marked as answer by Bill_Stewart Tuesday, June 17, 2014 6:10 PM
    Tuesday, May 13, 2014 3:50 PM

All replies

  • Are you looking something like this ?

    (Get-Item C:\Windows\assembly\GAC\VSLangProj80\8.0.0.0__b03f5f7f11d50a3a\VSLangProj80.dll).VersionInfo | sELECT -Property CompanyName


    Regards Chen V [MCTS SharePoint 2010]

    Tuesday, May 13, 2014 12:39 PM
  • Hi Chen

    Thats exactly what I was looking for. Thank you so much.

    Can I ask? How did you know that FileVersionInfo contains so many properties or what is it just general knowledge?

    If I run a command like this, it wouldn't be obvious that CompanyName is a property that can be found within Get-Item

    (Get-Item*)|Get-Member

    Cheers

    Matt

    Tuesday, May 13, 2014 12:50 PM
  • Simply like this

    Get-ChildItem -Path C:\Windows\assembly\GAC_64\BDATunePIA\6.1.0.0__31bf3856ad364e35\BDATunePIA.dll | Select -Property *

    You will now see VersionInfo

    and you can try this to explore more

    Get-ChildItem -Path C:\Windows\assembly\GAC_64\BDATunePIA\6.1.0.0__31bf3856ad364e35\BDATunePIA.dll | Select -ExpandProperty VersionInfo | fl

    Outputs

    OriginalFilename : bdatunepia.dll
    FileDescription  : BDA Tuning Model Primary Interop Assembly
    ProductName      : Microsoft® Windows® Operating System
    Comments         : 
    CompanyName      : Microsoft Corporation
    FileName         : C:\Windows\assembly\GAC_64\BDATunePIA\6.1.0.0__31bf3856ad364e35\BDATunePIA.dll
    FileVersion      : 6.1.7601.17514 (win7sp1_rtm.101119-1850)
    ProductVersion   : 6.1.7601.17514
    IsDebug          : False
    IsPatched        : False
    IsPreRelease     : False
    IsPrivateBuild   : False
    IsSpecialBuild   : False
    Language         : English (United States)
    LegalCopyright   : © Microsoft Corporation. All rights reserved.
    LegalTrademarks  : 
    PrivateBuild     : 
    SpecialBuild     : 


    Regards Chen V [MCTS SharePoint 2010]

    Tuesday, May 13, 2014 12:57 PM
  • When you use Get-Item C:\Temp | Get-Member

    You will observe the TypeName as System.IO.DirectortyInfo
    
    The versionInfo is available in System.IO.FileInfo


    Get-Item C:\Temp\Some.dll | Get-Member

    You will see the VersionInfo - this holds the company Name of DLL.


    Regards Chen V [MCTS SharePoint 2010]

    Tuesday, May 13, 2014 1:12 PM
  • Hi Chen

    When I run

    Get-Item C:\Temp\Some.dll | Get-Member

    The output is this but its doesn't say it holds the company Name  :-

    VersionInfo               ScriptProperty System.Object VersionInfo {get=[System.Diagnostics.FileVersionInfo]::GetVersionInfo($this....

    Tuesday, May 13, 2014 1:34 PM
  • Take a look at the properties available inside of VersionInfo:

    (Get-Item C:\Temp\Some.dll).VersionInfo | Get-Member


    Don't retire TechNet! - (Don't give up yet - 12,830+ strong and growing)

    Tuesday, May 13, 2014 1:44 PM
  • (dir C:\Windows\assembly\GAC\ADODB\7.0.3300.0__b03f5f7f11d50a3a\adodb.dll).VersionInfo | GM

    This will give a dice.

    Whatever the property you see is available in versioninfo :)


    Regards Chen V [MCTS SharePoint 2010]


    • Edited by Chen VMVP Tuesday, May 13, 2014 1:48 PM
    Tuesday, May 13, 2014 1:47 PM
  • Hi Chen

    Ta. I had tried that already. I was just trying to work out how you think to help me in future.

    My Help files within PowerScript are not up to date.

    Would this work if I had a full version of Powerscript installed on my PC?

    get-help company

    Cheers

    Matt

    Tuesday, May 13, 2014 1:48 PM
  • I am sorry Matt  I am not clear with your question. Do you still need help in this? I think you have already opened a forum question for help

    Do you need help in getting help file version information ?


    Regards Chen V [MCTS SharePoint 2010]

    Tuesday, May 13, 2014 1:52 PM
  • Hi Chen

    Yes please. If I ran this

    get-help company

    should this tell me which commands have the word company as a member?

    I could do with knowing how to seach through all cmdlets to see which contain the word company

    Cheers

    Matthew

    Tuesday, May 13, 2014 2:02 PM
  • I could do with knowing how to seach through all cmdlets to see which contain the word company

    Use Get-Command '*company*' to see if you get any results. Unless you have something unique, you may not see any results. This will show all results with 'help' in their names:

    Get-Command '*help*'


    Don't retire TechNet! - (Don't give up yet - 12,830+ strong and growing)

    Tuesday, May 13, 2014 2:08 PM
  • Hi Mike

    Get-Command '*company*'

    doesn't give me any output. My help files won't update at the moment (the Update-Help will not update the help files) - I'm going to obtain a manual help file from home and bring to work to import. If I still have trouble I think I will post a seperate topic regarding.

    cheers

    Matt

    Tuesday, May 13, 2014 2:12 PM
  • Even with updated help files you probably won't get any output. I don't know of any cmdlets that actually have Company as the verb or the noun.

    Don't retire TechNet! - (Don't give up yet - 12,830+ strong and growing)

    Tuesday, May 13, 2014 2:14 PM
  • Hi Mike

    I think your right. I am looking for a way to search for all property member names that contain the name Company. In particular I am looked for CompanyName which is a propery of file versions.

    Can you build me up a command?

    cheers

    Matt

    Tuesday, May 13, 2014 2:17 PM
  • That's going to be a pretty tall order, as you may need to search several levels into some of the cmdlets. What's your eventual goal here?

    Don't retire TechNet! - (Don't give up yet - 12,830+ strong and growing)

    Tuesday, May 13, 2014 2:47 PM
  • Hi Mike

    When I started learning Powershell, a few weeks ago, I watched YouTube video that stated that rule number 1 is to use Get-Help when searching for any topic that you need to know about. I kind of expected that that this would be as good or better than searching on the Internet.

    As a beginner and learning the commands, and about all the functionality, it would be useful to have this kind of tool. As in this topic, I was searching for where I could obtain the CompanyName of file. I know its not something that is commonly needed but nevertherless, I found that I had to post a discussion here to find the answer - thats fine but if I had a tool like this then it could save me time posting these kinds of queries and save any more embarassment on my behalf.

    If its not so simple, maybe the reason for that is that I shouldn't need such a tool but at the moment it feels like it would come in useful.

    cheers

    Matt


    • Edited by jmatty2000 Tuesday, May 13, 2014 2:55 PM
    Tuesday, May 13, 2014 2:54 PM
  • jmatty  - you are asking a question that shows you do not understand the difference between an object and a command.  Help only works for commands.  Objects must be inspected with Get-Member.

    Go back and spend time with a full training in PowerShell.  A couple of youtube videos will not be enough.  I recommend starting with a book.


    ¯\_(ツ)_/¯

    • Marked as answer by Bill_Stewart Tuesday, June 17, 2014 6:10 PM
    Tuesday, May 13, 2014 3:50 PM
  • Hi jrv

    Thanks, I was just looking at Amazon for a book - so far I've just bought a cheap Kindle one. They're all a bit pricy for PowerShell in my opinion but will keep an eye out.

    cheers

    Matt

    Tuesday, May 13, 2014 3:57 PM
  • Hi jrv

    Thanks, I was just looking at Amazon for a book - so far I've just bought a cheap Kindle one. They're all a bit pricy for PowerShell in my opinion but will keep an eye out.

    cheers

    Matt

    There are at least a dozen free books in PDF format which you can upload to your Kindle account.

    C'mon - you kids are supposed to be tech savvy. Certainly you don't think that this is not possible.

    Here is the book that started it all: http://www.sapien.com/blog/2009/12/01/free-windows-powershell-ebook/

    http://www.hofferle.com/list-of-free-powershell-ebooks/


    ¯\_(ツ)_/¯

    Tuesday, May 13, 2014 4:21 PM
  • Is this part of the "what DLLs get called as part of a particular program" project?

    I ask because if that's the case, I don't think there's really a scripting question here, is there?


    -- Bill Stewart [Bill_Stewart]

    Tuesday, May 13, 2014 5:08 PM
  • Hi Jrv

    I've downloaded http://www.sapien.com/books/Windows-PowerShell-2 and will see how far I get with the book. The other web-link looks handy as well. Thanks so much as that could make a massive difference in whether I'm successful with powershell in the end.

    Cheers

    Matt

    Wednesday, May 14, 2014 8:06 AM
  • Hi Jrv

    I've downloaded http://www.sapien.com/books/Windows-PowerShell-2 and will see how far I get with the book. The other web-link looks handy as well. Thanks so much as that could make a massive difference in whether I'm successful with powershell in the end.

    Cheers

    Matt

    When you read the V2 book be sure to try every example.  If you do that and  do not move forward until you are sure you understand then you will quickly become very adept at PowerShell. 

    When running the examples you want to start PowerShell inV2 mode like this:  powershell version 2

    If you only have V2 installed then you will not need that.  WIndows 7 and later may have V3 or V4,  XP and WS2003 can only have V2.


    ¯\_(ツ)_/¯

    Wednesday, May 14, 2014 1:10 PM
  • Hi jrv

    Will do that. I just realised that I've downloaded the v2 Sample book. I can obtain a fairly cheap v2 second hand book from Amazon rather than purchasing at full price.

    I've got a dilmma now - to either purchase a v2 book thats year 2010 or pay a bit more to obtain v3 or v4 --- Aaaahhh!!

    Cheers

    Matt

    Wednesday, May 14, 2014 1:24 PM
  • I'd only buy the latest. You can get the older v2 stuff free on the intarwebs.

    Don't retire TechNet! - (Don't give up yet - 12,830+ strong and growing)

    Wednesday, May 14, 2014 1:30 PM