Ramon TAN

Forum Replies Created

Viewing 15 posts - 121 through 135 (of 138 total)
  • Author
    Posts
  • in reply to: Is it possible break out of a Foreach loop? #102610
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Many thanks Mr Sallow, your tips are very useful to me.
    Much appreciated.

    in reply to: EXCEL methods and properties in PS 5.1 #102560
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Much thanks Mr Crompton. Your answers are extremely helpful and educational for me.
    My sincerest gratitude for your assistance.

    in reply to: Is it possible break out of a Foreach loop? #102559
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Thanks Mr Crompton for this wealth of information, offering numerous insights and giving me an increased understanding on how to use PS’s features. The second solution, to filter them early on at the CSV file stage, seems the smartest! Much thanks.

    in reply to: Is it possible break out of a Foreach loop? #102557
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Many thanks Don, much appreciated.

    in reply to: EXCEL methods and properties in PS 5.1 #102538
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Hello Mr Crompton,
    Thank you very much for your inputs — they are extremely useful for what I am striving to do. While I was looking to various blog sites, I cam across one post which was rather interesting. It had to do with accessing those deeply-buried Enum values and the like. One such example (from the 4 or 5 that the author listed) is (I was interested in changing cell borders) —

    [Enum]::getvalues([Microsoft.Office.Interop.Excel.XlBordersIndex]) |
    select @{n=”Name”;e={“$_”}},value__

    But when I ran this, I got the following error message:
    Unable to find type [Microsoft.Office.Interop.Excel.XlBordersIndex].
    At line:2 char:19
    + [Enum]::getvalues([Microsoft.Office.Interop.Excel.XlBordersIndex]) |
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (Microsoft.Offic….XlBordersIndex:TypeName) [], RuntimeExc
    eption
    + FullyQualifiedErrorId : TypeNotFound

    Clearly, I need to install (?) some missing pieces from Microsoft. It’s not critical for me to be able to change borders/etc.. It’s just interesting to know that this exists. Would be grateful for any additional tips or pointers. Many thanks!

    in reply to: Save versus SaveAs in PS 5.1 #102436
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Many thanks Jim …

    I dug further into the MS Technet wesbites and it turns out there is no Save() method for Worksheets — but there is a Save() method for Workbooks.

    https://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet_methods.aspx
    https://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.workbook_methods.aspx

    I do not really know the root cause … but perhaps that may explain why I got those 3 or 4 extra lines with the “Overload Definitions” message. As suggested I changed Line 9 of the code in the Forum post to:

    $book.Save()

    and it executed without errors. But when I attempted to open the resultant file, it (EXCEL) gives an error message about the file type being the wrong type or is corrupted. This is the same behavior as another earlier problem which I posted before this one, and for which the solution that works (thanks to another Forum participant) is:

    $Excel.Workbooks.Item(1).SaveAs(,51) <<< the '51' is to Save to .XLSX Open XML format

    with Item(1) being the worksheet in question.

    Many thanks for your inputs, they have led me to more interesting insights and discoveries.
    Much appreciated!

    Best,

    in reply to: Converting EXCEL files in Powershell #102416
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    My sincerest thanks, Mr Joel Sallow.
    I have read the URL reference documentation and followed your solution and it works perfectly.
    Your response was very helpful and informative/educational!
    Best,

    in reply to: How Do I CONTINUE TO the NEXT LINE in a script? #102152
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Very nice, Very NEAT!!!
    Mr Jones, I am extremely grateful for your website Powershell.org’s Q&A Forum.
    I have learned tremendously in a few weeks time, mostly from examples in your book.
    Your unique approach, which is to point the learner in the right direction, increases learning beyond getting just the answer, like math problems/exercises in a textbook: getting into the solution(s) process is more critical than getting the answer.
    But the most valuable source of knowledge and know-how to me is this Q&A Forum.
    More power to you and your team for their excellent work and willingness to share your knowledge.

    Best,
    RTan

    in reply to: How do I get the VALUE of a Property (in an object)?? #102146
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Thank you! It works perfectly. The documentation on the -ExpandProperty parameter is limited, so I do not claim to understand what it is really doing behind the scenes. All I know is that in the object-oriented world of Poweershell (which is great!) there are other “new properties” – e.g., AliasProperty,NoteProperty – that have been added to the original Property concept in object-oriented approaches. Would be grateful if you can point me to references/sites/docs that explain the -ExpandProperty in more detail. Thanks again.

    in reply to: How do I get the VALUE of a Property (in an object)?? #102143
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Yes, you are right. Many thanks for giving 2 ways of doing the same thing.
    While I do not yet know the finer differences between WmiObject and CmiInstance, I hope to read about them in order to appreciate which one is more appropriate under certain specific conditions, and other finer aspects as efficiency, etc..
    My sincerest thanks for your technical tip, it has enhanced my learning process.

    in reply to: How do I get the VALUE of a Property (in an object)?? #102142
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Many thanks, Mr/Ms Bakhtyar … your solution not only worked, but it made me realize why Get-ItemPropertyValue (which I was struggling to “make it work”) does not work.
    Best,

    in reply to: Execution order of commands in scripts #102077
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Thank you very much Mr Jones!
    Indeed, I changed the last line to add a pipe to:
    Out-File zzz.txt
    and the expected outputs were there. I have 2 more related questions.

    Question-1:
    I have been using files instead of variables, but generally, is it better to store such “temporary results” which are headed for more “textual massaging” in variables or files? The kind of temporary results I have in mind are not “big” nor “voluminous”, i.e., no more than a few hundred lines, totalling no more than 10K bytes. If this question does not make sense, please ignore.

    Question-2 (what is the syntax for a script block’s contents?):

    I still cannot find the documentation for the proper syntax inside a “script block” { }. For example:
    (Get-content AAA.txt) | Foreach-object {_$ -replace “ooo”,”ZZZ”} | Set-content AAA.txt

    What are the “allowable parameters” besides “-replace”? I am eager to know the full suite of what’s allowed inside the { } block. Is there an IF-THEN-ELSE equivalents for simple processing?
    I’ve already discovered the .NET methods that can be easily used (Contains, ToChar, Substring, Compare, etc.) but need to know where documentation exists for script blocks, specifically for Foreach-object { }.

    Sincerest thanks to you for your help.
    Best,
    RTan

    in reply to: Export vs. ConvertTo – what's the difference? #101872
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Much thanks, Mr. Rob Simmers.
    Your inputs are very helpful to me.
    Best,

    in reply to: How do I "get" the Contains method? #101845
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    Thank you very much Mike … it now works. But I must be missing something fundamental in my understanding of PS as it relates to using existing methods in .NET. I cannot understand why the first few times I was writing simple 1-line code such as:
    $a = “example”
    $d = $a.Contains(“ample”)
    I was getting the error message. And then a few repeated commands later, the error message no longer appears.
    I hope to figure this out in due time.

    Sincere thanks for your help.

    in reply to: How do I filter the PS Blog Q&A? #101691
    Participant
    Topics: 86
    Replies: 138
    Points: 677
    Rank: Major Contributor

    That was FAST … Thanks very very much, and more power to you and your team @Powershell.org.

Viewing 15 posts - 121 through 135 (of 138 total)