Why can't I run a powershell file I created from a powershell function

Ok so admittedly I am still learning a lot about powershell so this may have a very easy explanation/solution
So I have this script file and this is it in its entirety 
function Add-DriveFunctions($Provider, $Path)
foreach ($Drive in $Provider.Drives)
if ((Get-Command | where Name -eq "$($Drive.Name):") -eq $null)
[String]"function $($Drive.Name):() {Set-Location $($Drive.Name):}" | Out-File $Path -Append
$Path = C:\Temp\test.ps1
"""Adding Drives""" | Out-File $Path
foreach ($Provider in Get-PSProvider)
Add-DriveFunctions -Provider $Provider -Path $Path
C:\Temp\test.ps1
When I run it it happily creates the ps1 file whose content looks like this
 "Adding drives"
function Alias:() {Set-Location Alias:}
function Env:() {Set-Location Env:}
function Function:() {Set-Location Function:}
function HKLM:() {Set-Location HKLM:}
function HKCU:() {Set-Location HKCU:}
function Variable:() {Set-Location Variable:}
But the last line to actually load and run the ps1 file does nothing
even calling C:\Temp\test.ps1 does nothing
but if I load the file into ISE and run it from there
it works.
Unless I'm completely missing something I would think being able to call other ps1 files from other ps1 files or the command line would be a pretty important part of powershells flexibility.
So if anyone could tell me why in this case it does not work I would greatly appreciate that
Cheers,
Quidquid latine dictum sit, altum videtur

Ok i'm a little confused 
in ISE if I write a ps1 file and i have just a function in it not anything calling that function when i run or debug it loads that functions definition into the current session and then from my console i can access my function. so Is that what the . is supposed
to do?
When i tried the . I get this
The term '.C:\Temp\test.ps1' is not recognized as the name of a cmdlet, function, script file, or operable 
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try 
again.At C:\Users\rjs012978\Downloads\FunctionTest.ps1:20 char:1
+ .C:\Temp\test.ps1
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (.C:\Temp\test.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Also I know i can do that with the mono letter drive but working on a network over half the alphabet is taken up by my actual network mapped drives.
And the provider i'm writing is connecting to multiple Space IDs that i'm making into my drives so I would quickly run out of letters.
proof of concept i know what i'm doing works if I do it manually
I know it's kind of silly but for me the amount of time i spend in powershell especially administering SCCM, the registry and AD being able to just type hklm: and hitting enter is a huge time save over the long haul than typing cd hklm: even though it's
just 3 more characters
Quidquid latine dictum sit, altum videtur

Similar Messages

  • Why can't I open DVD-RTAV files on iMovie from my HDD video camera?

    Why can't I open DVD-RTAV files or RTR-EXTN on iMovie from my HDD video camera? I'm not sure which one has the video files anyway. Does anyone know how to import these to iMovie? Thx

    rodhamilton wrote:
    ...  I'm not sure which one has the video files anyway. ...
    none.
    tell us manufacturer and type/model of cam you're using ...

  • Why Can't I Open My PNG Files? Going from MAC to PC

    I created .png files in Photoshop CS on my MAC. Now I can't open them in Photoshop 6 on my PC running Windows Vista. Why? The files open as blank. All .jpg and .psd files open with no trouble.

    I just installed PhotoShop 6.0 on from an old disk (licensed) onto my laptop Toshiba PC running Windows Vista. I have had no problems so far except for this .png issue. I basically just wanted a high-resolution image with a transparent background. I suppose I could try to save them again as uncompressed .psd images on my MAC and try opening them again on the laptop...but I hate having to do weird things like that. png should work!

  • Why can't I open a pdf file on my desktop?  I keep getting this message: Adobe Reader could not open '8pdk_96_4.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and w

    Why can't I open a pdf file on my desktop?  I have Adobe Reader and running OS 10.10.1  I keep getting the same message: "Adobe Reader could not open '8pdk_96_4.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)."

    I tried that.
    I saved the file 8pdk_96_4.pdf to my desktop and tried to open it using Adobe Reader but I get the same message: Adobe Reader could not open '8pdk_96_4.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).

  • Why can't PSE 9 find the file to load styles?

    Why can't PSE 9 find the file to load styles

    Use Task Manager to kill any running processes associated with PSE, then reboot. 
    Use Control Panel's Programs and Features to uninstall PSE. 
    The use Windows Explorer to delete any remaining PSE directories following these directions (change the names to version 10):
    http://helpx.adobe.com/photoshop-elements/kb/manually-remove-photoshop-elements-9.html
    Reboot.
    Re-install PSE9.
    Ken

  • Why can't I run my Java program with just the JRE, the JDK is required?

    I've recently written 3 programs in Java using the Netbeans IDE with JDK 1.6 as the default Java platform. The compile-time libraries include the Swing Application Framework. I use BuildDesk from ProductiveMe to package the each program into a Windows installer.
    When I install the programs on a new computer without a JRE or JDK being present, and attempt to run them I get an error (as expected) stating that there is no JVM. The messages says that I need to install JDK 1.3 or higher. I downloaded the latest JRE onto the new computer and attempted to run the programs and I get the same error message. My question is, why can't I run these programs with just the JRE installed? Why do I need the JDK? When I install the JDK, the programs run fine. The typical user may not have the JDK on their system, but they likely have the JRE if they've run Java programs before.
    Is the answer as simple as there must be library functions being used by the programs that belong to the JDK, but not the JRE? I'd rather a user not have to install the JDK verses the JRE because they may also have to update some Windows environment variables.
    Thank you for any help on this issue.

    915088 wrote:
    Thanks for your replies. I further investigated BuildDesk and found an option which allows a JVM check but that check needs the JDK. I stopped the JVM check and rebuilt using BuildDesk and it now only requires the JRE to run the programs. The reason why I use BuildDesk is to package more than just the jar file for the user. BuildDesk allows me to create a installation folder structure as well as include any other files in the build. I could just as well zipped all this together for the user but decided against that method.I don't think anyone will question your usage of an installer tool; that is entirely up to you. But what is questionable is that you have problems with that installer tool and then go look for help in a Java programming forum. The next time, go look for help at the source. If there is no way to acquire help (support, a forum, a mailinglist, anything) then that is a very good reason to not use the product in question.

  • Why can't I open any PDF files ?

    Why can't I open any PDF files ?

    I am running Safari Version 5.1.5 (6534.55.3) on my iMac 10,1.  After my last Adobe update, my pdf files are nothing but a black window.  Have tried reverting to an earlier version of Adobe, but still getting a black window.  What next steps should I take?  Thanks.

  • Why can´t I Export my H264 file as a VMW file in quick time 7. The program only does 30 seconds?.

    Why can´t I Export my H264 file as a VMW file in Quick time 7pro. The program only does 30 seconds of the file?

    Why can´t I Export my H264 file as a VMW file in Quick time 7pro. The program only does 30 seconds of the file?
    The Windows Media codec you are using is running in the "demo" mode. To export full clips you must purchase or upgrade to one of the export capable codec components like those included in the "Studio" or "Studio Pro HD" software package.

  • Why can't i print a pdf file, it's asking for a password and i have no idea what it is it's never asked me before?

    why can't I print a pdf file, it's asking for a password and I have no idea what it is it never asked for one before?

    Good afternoon SaraThanks for responding. Yes, I have been able to open these files before without a password. Funny thing is it is happening on both my husband's laptop as well as mine. I'd appreciate any help you could give me but the file is very personal. So, if you can assist in a way that won't compromise the security I would be grateful for your help.Thanks and have a great day!Kim Morse 

  • Why can I no longer import Mp4r files from my desktop (Macbook Pro) to iTunes??

    Why can I no longer import Mp4r files from my desktop (Macbook Pro) into Itunes?  Seemed to work perfectly well before the latest upgrade.  Feeling quite annoyed, especially when all the forums seem to give the same advice, which no longer seems to work!!  Please can someone help!  Uploading a file should not be this difficult!!!

    Make sure you have the Quicktime Player 7 installed.  It was an option when installing Lion.  Or you can get it here: QuickTime Player 7 for Mac OS X v10.6.3 or later.  Install it, reboot and try again.
    OT

  • Why can't I see my iPhoto files in iMovie?

    [DISCLAIMER: My question is short, but my details are not. This is going to be a LONG read, but I wanted to make sure I provided all you helpful people with as much information as I could so that I could receive the best possible solution. So your patience and assistance is greatly appreciated!]
    In iMovie [version 4.0.1], when I click on the Photo button to import pictures into my project from iPhoto, the following error message appears: "No photos were found. To use this feature, you must first create a photo library using iPhoto version 2.0 or later."
    However... I AM using iPhoto [version 4.0.3]... with a HUGE Library containing 2000+ images and several created albums. These features work just fine within the confines of that program. They just aren't integrating with iMovie correctly. So... why can't I see my iPhoto files in iMovie?!!?!
    FIRST ATTEMPT:
    When I checked iMovie help, all it said was "You must open iPhoto at least one time on your computer to be able to access your iPhoto library from iMovie." I've obviously done this, having used the program plenty. Didn't work.
    SECOND ATTEMPT:
    When I checked this forum, the closest thread I could find that was similar to my problem suggested deleting the iMovie preferences file [com.apple.imovie3.plist]. It was later added that deleting the iPhoto preferences file [com.apple.iphoto.plist] as well had solved the problem immediately for that user. Tried it. Didn't work.
    THIRD ATTEMPT:
    When I checked the Apple Info site, their main solution was to try recreating the AlbumData.xml file which is used to populate the photo listing. Now this file can usually be found in the iPhoto library folder and I know how to recreate it. But THIS is where I think my main problem lies.
    Unlike most users, my iPhoto Library is actually located on an external hard drive under "my hard drive name"/Pictures/iPhoto Library. When I checked this folder for the AlbumData.xml file , it simply did not exist. So as a test, I created a new iPhoto Library also on my external hard drive but the AlbumData.xml file was not created with it. I opened up iMovie just to see if it was able to browse the iPhoto library properly. But it still didn't work.
    However, when I created a test iPhoto Library directly onto my Mac's hard drive, the AlbumData.xml file was indeed created with it. And when I opened up iMovie again... lo and behold, the iPhoto library finally appeared. It worked. But unfortunately, this solution still doesn't help me at all!
    Thing is, I don't have enough space on my Mac's direct hard drive to move my entire iPhoto Library there (where it works). That's why I am using an external hard drive to store (more space). So is there ANY way I can keep my iPhoto Library located on my external hard drive and have the library, albums and files recognized in the other iLife applications like iMovie???
    I feel I've tried everything, folks Could someone please please help me?!!?!
    [my specs are listed below if that helps any]
    Thanks in advance,
    a very disgruntled wizkid :\
    PowerBook G4 12" [1GHz, 256MB, 40GB]   Mac OS X (10.3.9)   GeForce FX Go5200 32MB, Matshita DVD-R UJ-816, Maxtor External Hard Drive [250GB, Firewire & USB 2.0]

    My main concern at this point is that the AlbumData.xml file is unable to create itself onto the External HD. When I view the file [that I created from my test iPhoto Library on my Mac's HD] in finder, it appears to be a Final Cut Pro type of extension. Is something wrong with my External Hard Drive in that regard? Is it just incapable of storing those file types??? Hmmm...
    As for the alias solution... instead of alias-ing the "Pictures" folder like you have, I've already tried creating an alias of the "iPhoto Library" folder on my External HD and placing it within the "Pictures" folder on my Mac. But when I tried to "Find Library" upon launching iPhoto, the prompt box would not allow me to choose the "iPhoto Library" alias I had created. So I couldn't open it.
    To be honest, I'm not exactly sure how to create an alias correctly... or perhaps I should try alias-ing the actual "Pictures" folder (like you have) rather than just the "iPhoto Library" folder, but I don't know how to do that correctly either.
    FYI... I am mounting my External HD before I launch iPhoto.
    Also, I have also tried dragging the AlbumData.xml file that I created from the test iPhoto Library into my active iPhoto Library folder residing on my External HD. It would appear to be in the folder, but as soon as I clicked somewhere else in finder and than back into the folder, it would disappear. Not sure how to "point to it" either.
    Karl, think maybe you could provide some hints on how to properly alias something or "point" to the AlbumData.xml file? I'd try it myself, but I don't wanna screw anything up by accident.
    PS. As stated in the post above, there's a possibility my External HD is no longer Mac OS formatted... at which point I throw my hands up into the air and scream!
    thanks for the tips thus far... everyone's so nice and helpful... I love it!
    -the kid
    PowerBook G4 12" [1GHz, 256MB, 40GB]   Mac OS X (10.3.9)   GeForce FX Go5200 32MB, Matshita DVD-R UJ-816, Maxtor External Hard Drive [250GB, Firewire & USB 2.0]

  • Why can't i run itunes on my windows 8?, why can't i run itunes on my windows 8?

    why can't i run itunes on my windows 8 laptop..?

    Hi sincerelystef,
    If you are having issues installing iTunes on your Windows machine, you may find the following article helpful:
    Apple Support: Trouble installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/HT1926
    Regards,
    - Brenden

  • Why can't Bridge open my raw files from Canon PowerShot 120-S? Using PS/5

    Why can't Bridge open my raw files from my new Canon Power Shot 120-S camera? I'm using PS-5 and had no problems with other Canon cameras. I downloaded Adobe Camera Raw 8 but this has not resolved the problem.
    Jack

    1. you need cr 8.3+ for the Canon PowerShot S120
    2. ps cs5 can only update to cr 6.7
    free solution: use the dng converter: http://www.adobe.com/support/downloads/detail.jsp?ftpID=5694
    integrated solution: upgrade to ps cc.  here are the options (but especially note the photographer plan for 9.99/mo) - http://www.adobe.com/products/photoshop/buying-guide.html

  • Why can't I open my RAW files in my trial version of Photoshop Lightroom 4?

    Why can't I open my RAW files in my trial version of Photoshop Lightroom 4? I use a Canon 5d mark II, which is supposed to be supported, and I checked for updates, but none were found.

    You cannot open files directly with Lr.
    You have to import them.
    Watch this tutorial video: http://tv.adobe.com/watch/getting-started-with-adobe-photoshop-lightroom-4/lightroom-4-imp orting-and-organizing-your-images/

  • Why can't I send a pdf file by email?

    Why can't I send a pdf file by email?

    How are you trying to send it? What happens when you try? What version of Reader?

Maybe you are looking for

  • HT4623 My iPad will not allow me to download any apps

    My iPad will not let me download any apps, also in the APPS STORE it shows a '1' meaning that there is one new update, it will not even let me update.  Also when browsing some websites like BT, it shuts down and reverts back to the home page of all m

  • How can I change the number of pages in a spread?

    I imported a document that our PR department used to create in Quark into InDesign 5.5. They have it set up in four-page spreads. However, the document has always been printed with a coil binding with a large graphic on each left-hand page and text o

  • Short dump while executing few queries , which has got created on Infoset.

    Hi, We went to BI7.0 upgrade from BW3.x now. We are getting short dump short dump while executing few queries and work book, which has got created on Infoset. When i was executing work book where i was geting popup message saying that "Erro ZSD_XST_F

  • [Athlon64] Promise/SATA/Promise/RAID/Promise! What's it all mean?

    I've been reading up on some of the RAID information scattered around the Internet, and I've also been reading the booklets bundled with my MSI motherboard. My questions lean more toward the meaning of Promise and its various "forms" (?), and I think

  • My lumia 1020 can't be recognized on my windows 7 ...

    When I plug my lumia 1020 to my pc the only thing that happens is a pc sound telling me that something has happened. But I cant se my lumia at all. What's wrong and what do I do? Solved! Go to Solution.