Why is Get-Content inserting extra subdirectories in directory path

Can someone please look at the following 6 lines of code and explain the output I'm receiving?  I've been looking at the code segment for a week trying to figure out what could possibly be wrong and I can't.  At this point I'm convinced it's a
weird powershell bug - but I'd be happy if someone here could prove me wrong, explain what I'm seeing and tell me how to correct it.  "logit" is irrelevant to the issue - it's just a simple function which calls tee-object to print the line to
the screen and write it to a file.  I added the here string code just to inspect what the line looks like after substitution.  The value of $servertype when this code snippet runs is "Core" (as you can see in the output).
> echo "Substituting data into C:Temp\Setup-$servertype\updates\Media\travel\con.html" | logit
> $here = @"
> inputfile =  get-content "C:Temp\Setup-$servertype\updates\Media\travel\con.html"
> "@
> $inputfile = get-content "C:Temp\Setup-$servertype\updates\Media\travel\con.html"
> echo "The here string is: $here" | logit
Here is the output from the above code...
2015-01-28T13:54:05 - jim -  - Substituting data into C:Temp\Setup-CORE\updates\Media\travel\con.html
get-content : Cannot find path 'C:\Temp\Setup-Core\Temp\Setup-CORE\updates\Medi
a\travel\con.html' because it does not exist.
2015-01-28T13:54:05 - jim -  - The here string is: inputfile =  get-content "C:Temp\Setup-CORE\updates\Media\travel\con.html"
I deleted the extra error info from the above output to illustrate the problem more clearly (I'll paste it below).  The problem is that the path that cannot be found has the first 2 directory levels duplicated (C:\Temp\Setup-Core\Temp\Setup-CORE\...)
instead of (C:\Temp\Setup-CORE\...) - note the difference in the case of the word "Core". 
How and why could this be happening - and what do I need to do to make this work properly?
Thanks in advance to anybody who takes the time to reply.  Here are the missing lines from the output above (I'm pretty sure it's not relevant):
At C:\temp\setup-CORE\scripts\travel.ps1:196 char:14
+ $inputfile = get-content
"C:Temp\Setup-$servertype\updates\Media\travel\co ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : ObjectNotFound: (C:\Temp\Setup-C...el\con.ht
   ml:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCo
   ntentCommand

@jrv - Please learn to be more polite and less like a pompous ass.
I've been staring at the problem for a week before reaching out for help.  Yes it's a stupid typo that I should have seen during one of the dozens of times I reviewed the code - but I didn't.  I'll bet you've encountered stupid mistakes before
too.  Posting a rude, arrogant comment on this thread after someone had already answered my question is something only a jerk would do.
Please learn to read the messages.
I said please.  How polite do you want it.  You need to learn to use the information that is right in front of you.  It willsave you all of those wasted weeks caused by refusing to take well intended advice.
¯\_(ツ)_/¯

Similar Messages

  • PS Get-Content - file containing environement variable

    Hello
    I have an issue with a script where I have a text file containing folders and files. I get them with Get-Content and then I copy them somewhere else.
    My problem is that I would like to be able to use environement variable in the text file, like D:\$env:USERNAME\Documents but when I get them through Get-Content, variable are not converted.
    Is there a way to make Powershell recognizing variables in the path ?
    Thanks !

    Invoke-Expression is not needed in this case. I recommend the $ExecutionContext.InvokeCommand.ExpandString method instead.
    -- Bill Stewart [Bill_Stewart]
    I'm open to suggestions, (even though what I suggested was demonstrated and works).
    I took your advice and tried your suggestion
    PS C:\Users\User>
    Add-Content C:\liste.txt 'D:\$env:USERNAME\Documents'
    Add-Content C:\liste.txt 'D:\Documents'
    $sourcelist = get-content C:\liste.txt | foreach-object {
    $ExecutionContext.InvokeCommand.ExpandString($_)
    There is no output? So I tried assigning it to a variable.
    PS C:\Users\User>
    Add-Content C:\liste.txt 'D:\$env:USERNAME\Documents'
    Add-Content C:\liste.txt 'D:\Documents'
    $sourcelist = get-content C:\liste.txt | foreach-object {
    $Path = $ExecutionContext.InvokeCommand.ExpandString($_)
    $Path
    LOL, there is still no output. 

  • IF statement inserts extra line.

    I am having problems with IF statements inserting extra lines;
    POH_VENDOR_NAME<?if:POH_PO_NUM != ''?>(POH_PO_NUM)<?end if?>
    Returns:
    Consolidated Supplies
    (1085)
    Instead of:
    Consolidated Supplies (1085)
    I have tried using CHOOSE but get the same results. Any help appreciated.
    Thanks
    Carl.

    Hi Carl,
    Hope your development is going ok. Not sure why the choose wouldn't work with @inline, if the IF statement did. What I would suggest instead is using a series of IF statements. So <?if@inline:x=1?> and the opposite <?if@inline:x!=1?>
    Its a bit of a pain, but I can't think of any other way to get around this.
    Regards,
    Cj

  • Why queues get blocked in XI

    I have observed thet queues in XI get blocked even though there is no error.
    When I unlock it , Queues get cleared.
    Please let me know why queues get blocked .
    Thanks in Advance.

    Hi,
    Queues might get blocked to various reasons.
    The reasons i can think of are:
    1) Contention for resources : If there is a contention for resources like memory, the first message of the queue gets blocked, causing subsequent messages to be blocked as well.
    2) Huge messages: HUge payloads choke the queues.
    3) Receiving system processing the messages slower than the sending system.
    Regards,
    Ravi Kanth Talagana

  • What is wrong with my Get-Content

    I have a very simple script that for some reason fails me when I try to use the Get-Content issue. 
    $scriptLoc = [string](Get-Location)
    $path = $scriptLoc + '\temp_folder\'
    $files = Get-ChildItem -Path $path -filter hello*.txt
    write-host $files
    So this works fine. It goes to this destination. C:\Scripts\temp_folder
    In this folder are two files. 
    1. hello_dave.txt
    2.bye_dave.txt
    when I run the script above it successfully only shows file 1.
    So why does it fail with this?
    $file = Get-Content $files
    Actually I know why it fails, but why it fails make no sense. It returns an error saying that it cannot find the path. 
    The path it lists is not the one I have setup. This is the folder the txt file is in, and what I have setup earlier. C:\Scripts\temp_folder
    This is what it returns instead. Cannot find path 'C:\Scripts\hello_dave.txt' because it does not exist. 

    Please, before telling people they are making up stuff do test the exact steps as posted, we call it reproducing the issue.
    But don't bother I did it for you:
    PS C:\scripts> $scriptLoc = [string](Get-Location)
    PS C:\scripts> $path = $scriptLoc + '\temp_folder\'
    PS C:\scripts> $files = Get-ChildItem -Path $path -filter hello*.txt
    PS C:\scripts> write-host $files
    hello_dave.txt
    PS C:\scripts> Get-Content $files
    Get-Content : Cannot find path 'C:\scripts\hello_dave.txt' because it does not exist.
    At line:1 char:1
    + Get-Content $files
    + ~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (C:\scripts\hello_dave.txt:String) [Get-Content], ItemNotFoundException
        + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
    PS C:\scripts> Get-Content $files.PSPath
    test
    Your example works fine but not in the contest of the reported issue. As you can see $files is not NULL but resolves to C:\scripts\hello_dave.txt 

  • Why does DW disable insert menu items?

    This must be a configuration option someplace, but in general, why would DW disable Insert menu items?
    I am in .cfm file, in clearly an unlocked area of a page where I should be allowed to insert hyper links, email links, horizontal rules, images, tables.  But on the Insert menu, each of those items is disabled (and others, but you get the point).  Since the insert menu items are disabled, the keystroke shortcuts for those actions don't function.
    I can manually type in these tags, and I can insert them from the Insert window.
    I start a brand new .cfm page, and the insert menu is fine.
    It appears DW is examining the code and deciding [INCORRECTLY] what is appropriate to insert via the menu.
    Thanks for any insight provided.

    > Dreamweaver is putting the PHP href code (<a
    href="../st_vimmel.php"> code
    > </a>) not me?
    That's plain HTML, not PHP, and DW doesn't do that - really.
    > Can Flash also fix the <embed> tag (take away) as
    the W3C HTML validator
    > don't
    > accept this tag?
    DW's javascript solves that problem.
    > I fixed the problem flash image with a workarround code
    for the moment:
    *DON'T DO THAT*
    Leave DW's code alone.
    > To get away from all the javascript and other code that
    could be the
    > problem.
    It is not the problem, most likely - but tell us what the
    problem was.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Magooi" <[email protected]> wrote in
    message
    news:edie10$529$[email protected]..
    > Dreamweaver is putting the PHP href code (<a
    href="../st_vimmel.php"> code
    > </a>) not me?
    >
    > Hmm, where do I put the href i Flash?
    >
    > Can Flash also fix the <embed> tag (take away) as
    the W3C HTML validator
    > don't
    > accept this tag?
    >
    > I fixed the problem flash image with a workarround code
    for the moment:
    >
    >
    quote:
    <object type="application/x-shockwave-flash"
    > data="/images/banners/25000.swf" width="438"
    height="280">
    > <param name="movie"
    value="/images/banners/25000.swf">
    > <param name="quality" value="high">
    > </object>
    >
    > To get away from all the javascript and other code that
    could be the
    > problem.
    > My side is a bit complex with PHP/MySQL and many
    javascripts so I think
    > there
    > was a conflict with my admin system using MySQL or
    something.
    >

  • Get-Content not grabbing all machines in a text file

    Good Afternoon,
    I am running a script that I found on another page to determine if a particular service is running on multiple computers.  
    I am testing this for future use.
    Here is the syntax in the ps1 file:
    $computers = Get-Content -Path C:\Temp\serverstest.txt
    Get-Service -ComputerName $computers -Name "Service Name" | Select Name, MachineName, Status
    The text file has five server names in it.  There are no spaces at the end of the name or extra lines after the last one. The script will run but it only returns the first server in the text file. Here is what the text file looks like
    The output is this:
    Name                                       Machine Name           
    Status
    ccmexec                                   cmgrtstqw1               
    Running
    That is all that is returned.  It does not look like it is grabbing all the servers in the list to report against.
    I figure I either mistyped something or goofed it somehow.
    Thoughts or suggestions.
    PS...I have to say that I have found the Scripting Guys Forum IMMENSELY helpful in understanding Powershell....Thanks

    Hi,
    Looks like this is a PS 2.0 thing. Try this instead:
    Get-Content .\pcList.txt | ForEach {
    Get-Service -ComputerName $_ -Name 'CcmExec' | Select Name, MachineName, Status
    Don't retire TechNet! -
    (Don't give up yet - 12,700+ strong and growing)

  • Why is the contents of Safari's downloads folder different than the actual folder?

    Why is the contents of Safari's downloads folder different than the actual folder that resides in my users folder?

    Problem is if I delete that .plist I'll delete those downloads.  I'm still able to launch those downloads from that location so that tells that file is probably not corrupted. I need to be able to located that folder and transfer the downloads from it before I do anything like this.  So that begs the question, where is that folder located?  When I do a folder search I'm taken to a Downloads folder, but it's not the one that is showing up from within Safari as it's contents are too different. 

  • I have a 120gb Classic that has no space left on it. i am going to buy a larger gb capacity ipod as soon as i get clearer instruction on how to get the old ipod content to the new ipod. How do you get content from one ipod to the other?

    how do you get content from one ipod to the new one? my content is on an external hard drive not on my pc and i have run out of space on my 120gb classic. can you get old ipod content to new? my itunes has only got short cuts, the real content is on an external drive? can this be done?? please help

    If the content is on an external drive, but your library knows where to find it, then it should all work. Connect your device, make some selections for what to put on it, and sync. If, on the other hand, your current iPod is the only place holding some of your media then see this user tip: Recover your iTunes library from your iPod or iOS device.
    tt2

  • Get a insert session value for SQL query at report

    Hi friends
    I created a global temp table and procedure to support web search form.
    and a search result report. The procudure
    gets search result from multip tables and
    insert into temp table --recordsearch. I can get value from temp table  by call procedure
    at SQL*Plus.
    However, I can not get this value by web report.
    How can I get this insert session value and pass to SQL query for report?
    Thanks,
    Newweb
    CREATE GLOBAL TEMPORARY TABLE recordsearch
    (emp_id          VARCHAR2(200),
    ssn               VARCHAR2(9),
    fname          VARCHAR2(200),
    lname           VARCHAR2(200),
    m_name          VARCHAR2(200)
    ) ON COMMIT PRESERVE ROWS;

    it possible that your web form does not have a persistent, dedicated connection. if you have connection pooling for example, multiple sessions will see the same instance of the GTT, so if one deletes it, then nobody sees it (or you can see others data). if the connections are not persistent, then they can disconnect between calls, deleting the GTT table.

  • How do I set up automatic downloads so that i only get content from specific devices?

    Hello! I was wondering if there was a way I could set up automatic downloads so I only get content purchased from certain devices. I have a MacBook Pro and a ipod touch. I share an apple id with my family for itunes but have my own apple id for icloud. In my family we have various other apple products (iphones and ipads) and I dont want most of the things that my family would download on their devices - just the things would happen to download on my ipod and computer.
    Thanks for the help,
    J

    jackson_7 wrote:
    Hello! I was wondering if there was a way I could set up automatic downloads so I only get content purchased from certain devices.........
    That's not possible sorry.

  • How do I get content from my iPad to show up on the tv screen using Apple TV without going thru iTunes?

    How can I get content from my iPad and my air book to show up on the tv screen using Apple TV, without going thru iTunes?

    You will need to use AirPlay to see that.
    Assuming both devices are on the same network and that AirPlay is not turned off on the Apple TV, then simply tap on the screen when you are watching content you wish to stream to your Apple TV, then tap the airplay icon that appears in the control bar, choose the Apple TV from the menu that appears.
    When displaying the content you wish to mirror on the iPad 2 (or better), iPad Mini, iPhone 4S (or better), double tap the home button (quickly) and swipe the bottom row of apps to the right to reveal the playback controls, tap the AirPlay icon and select your Apple TV from the list of available devices.

  • I have an Iphone 3Gs. I need to get contents of messages that were sent and received on the phone in June for evidence in court. I read online that the Iphone internal storage keeps all data done on phone in the storage. How do I get into it?

    I have an Iphone 36s. I need to get contents of messages that were sent on the phone in June of this year. I read online that the phone has an internal storage that keeps all data when phone is used and that this internal storage can be accessed. I need the contents of particular messages for evidence in court. How do I get into the internal storage? I've tried some of the methods that people post online, but none of them have been successful. Help!

    If you still have a backup from that point in time as part ofr your computer backup history, you could restore the backup folder, restore the phone from that backup and have the messages on the phone.
    More details about restoring from old backups can be found here: iPhone and iPod touch: About backups

  • Get-Content and add Date and Time in a new file

    Hello,
    in a existing file I have data like:
    1;Idle
    5;chrome
    1;spoolsv
    Now I need to grab the content and add date and time in front of each line and save it to another file like:
    07.04.2015;10:18;1;Idle
    07.04.2015;10:18;5;chrome
    07.04.2015;10:18;1;spoolsv
    But I don't have any idea how I could solve this challange. Does anyone have a helping hand for me?
    Greetings

    Hello,
    If you need a new file with the desired output try this
    get-content .\current.txt | Foreach-Object{ $dntv = (get-date) ; "$dntv" + $_} | Out-File newfile.txt
    regards,
    V
    Venu

  • My last pc crashed, how do i get content from ipod/iphone/ipad and previously purchased items back into itunes on pc?

    How do I get content back into itunes from ipod/iphone and ipad when old pc died and now have a blank itunes?

    check out this post by Zevoneer.

Maybe you are looking for

  • Crystal Report Integration Problem with VS 2012 Ultimate

    I installed Crystal Report (Support Pack 13 v.13.0.13.1597) for VS 2012 Ultimate. When I create a crystal report, the Crystal Reports Gallery didn't pop up. Instead it just jump to *.rpt file and shows one hell of a hex codes Did anyone faced the sam

  • SRM 7.0 Process Controlled Workflow-Level Type in Process level config

    Hello Experts, In SRM 7.0 for Process controlled workflow,for Level Type in Process Level configuration we have 3 different options 1) Approval with Completion 2) Approval 3) Automatic(System User) Can you plz explain what is the difference between t

  • How do  I use a variable from an Interface class?

    Right now I have three classes. First class is called Game and it extends my second class call Parent and also implements my third class call Source. Source is an interface class. I have a variable that I want to use in my Source class named Checker.

  • Join on Fact and Dimension tables

    Hallo users, I'm working on new rebuilding structur and I have this trouble: I need to Join more then one Items on the same dimensional table. How is the correct way? Have I to import the same table any time I need to join it, or is it enough a copy

  • F.13  does not clear all   documents

    Hi F.13    does  clearing of  some documents.   There are many  which  balance to zero.   I  have  set  following for  customer ZUONR, VBUND, WRBTR Thanks kamala