![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | save cmdlets Is there a way I can save cmdlets I have used in previous sessions? i.e. I want to be able to enter cmdlets I have used in the past after I close and restart PowerShell or after I reboot. These would be both for cmdlets I have written (.ps1 files) & those I have not. |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: save cmdlets Ryan wrote: > Is there a way I can save cmdlets I have used in previous sessions? > i.e. I want to be able to enter cmdlets I have used in the past after > I close and restart PowerShell or after I reboot. These would be > both for cmdlets I have written (.ps1 files) & those I have not. Yes you can using Export-Console, see http://msdn2.microsoft.com/en-us/library/ms714644.aspx , notice there's a bug: the exported console has a .psc1 extension not the .mcf extension the docs mention |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: save cmdlets Ryan wrote: > Is there a way I can save cmdlets I have used in previous sessions? > i.e. I want to be able to enter cmdlets I have used in the past after > I close and restart PowerShell or after I reboot. These would be > both for cmdlets I have written (.ps1 files) & those I have not. Sorry i misunderstood you, do you want to save and reload your history instead of the CmdLets (those are written in a .NET language like C#) and loaded via PSSnapIns? You can save your history, for example in CliXML format, by piping the output of Get-History into Export-CliXml PS> Get-History | Export-Clixml history.clixml Reload the history by piping the output of Import-CliXml into Add-History PS> Import-Clixml history.clixml | Add-History You can "dot source" your ps1 files in your profile, see the docs for more info http://msdn2.microsoft.com/en-us/library/aa717060.aspx Joris |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: save cmdlets This gives me an onscreen text display of previous cmdlets used in the previous session, but I want to actually b able to use these commands by pressing the up and down arrows on the keyboard, not just see what cmdlets were used. "Joris van Lier" wrote: > Ryan wrote: > > Is there a way I can save cmdlets I have used in previous sessions? > > i.e. I want to be able to enter cmdlets I have used in the past after > > I close and restart PowerShell or after I reboot. These would be > > both for cmdlets I have written (.ps1 files) & those I have not. > > Sorry i misunderstood you, do you want to save and reload your history instead of the CmdLets (those are written in a .NET language like C#) and loaded via PSSnapIns? > > You can save your history, for example in CliXML format, by piping the output of Get-History into Export-CliXml > PS> Get-History | Export-Clixml history.clixml > Reload the history by piping the output of Import-CliXml into Add-History > PS> Import-Clixml history.clixml | Add-History > > You can "dot source" your ps1 files in your profile, see the docs for more info http://msdn2.microsoft.com/en-us/library/aa717060.aspx > > Joris > |
My System Specs![]() |
| | #5 (permalink) |
| Guest | RE: save cmdlets In other words you want a permanent record of the commands you have run so that you can scroll through them in oder to rerun the commands. Afraid thats not possible with base PowerShell. You can add functions to your profile to make functionality avaialble but not in the way you want -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "Ryan" wrote: > Is there a way I can save cmdlets I have used in previous sessions? i.e. I > want to be able to enter cmdlets I have used in the past after I close and > restart PowerShell or after I reboot. These would be both for cmdlets I have > written (.ps1 files) & those I have not. |
My System Specs![]() |
| | #6 (permalink) |
| Guest | RE: save cmdlets OK. So what is the exact text I need to add to my profile file to make this happen? Not finding any info on how to do so on your blog. "RichS" wrote: > In other words you want a permanent record of the commands you have run so > that you can scroll through them in oder to rerun the commands. Afraid thats > not possible with base PowerShell. You can add functions to your profile to > make functionality avaialble but not in the way you want > -- > Richard Siddaway > Please note that all scripts are supplied "as is" and with no warranty > Blog: http://richardsiddaway.spaces.live.com/ > PowerShell User Group: http://www.get-psuguk.org.uk > > > "Ryan" wrote: > > > Is there a way I can save cmdlets I have used in previous sessions? i.e. I > > want to be able to enter cmdlets I have used in the past after I close and > > restart PowerShell or after I reboot. These would be both for cmdlets I have > > written (.ps1 files) & those I have not. |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: save cmdlets "Ryan" <Ryan@discussions.microsoft.com> wrote in message news:0AD68AE5-B901-4E3C-A861-7F5F118D755C@microsoft.com... > Is there a way I can save cmdlets I have used in previous sessions? i.e. > I > want to be able to enter cmdlets I have used in the past after I close and > restart PowerShell or after I reboot. These would be both for cmdlets I > have > written (.ps1 files) & those I have not. You can save an entire record of your PowerShell session with the Start-Transcript cmdlet. If you want certain functions to be part of your global environment then create a profile (if you doesn't already exist): if (!(Test-Path $profile)) { new-item -type file $profile } notepad $profile Then add your functions directly to this file. If you want your profile to be more modular then you can put your PowerShell function in a PS1 file and then dot source that file into your profile like so: .. "$home\My Documents\WindowsPowerShell\funcs.ps1" -- Keith |
My System Specs![]() |
| | #8 (permalink) |
| Guest | Re: save cmdlets "Keith Hill" <r_keith_hill@mailhot.nospamIdotcom> wrote in message news:16F16F6D-F4CA-4652-B683-0D7E084814AD@microsoft.com... > global environment then create a profile (if you doesn't already exist): Oops. That should say "if *one* doesn't already exist". I know you exist otherwise how would you be posting to this newsgroup. :-) -- Keith |
My System Specs![]() |
| | #9 (permalink) |
| Guest | Re: save cmdlets I have a profile.ps1 file set up, but there are some things that I should let you know of: - I have 18+ yrs experience with computers, but I am not as familiar w/ the areas of programming and networking. (I understand this issue doesen't involve networking.) - I don't know what the terms "global environment" and "modular" mean. - I think "session" means the timeframe during which I start and close powershell; during which time powershell already saves whichever cmdlets I have used. I'm sure you already understand this, but what I'm looking for is to be able to reuse any cmdlet I have used previously in powershell from the point at which I make the change I need to make forward. 1: So, do I need to put the following text into my existing profile: if (!(Test-Path $profile)) { new-item -type file $profile } > notepad $profile and, if so, does it matter where in the profile the text is placed? 2: What are functions and where within the profile do I add them? (I assume that "functions" are cmdlets that I have written). 3: If you want your profile to > be more modular then you can put your PowerShell function in a PS1 file and > then dot source that file into your profile like so: > > . "$home\My Documents\WindowsPowerShell\funcs.ps1" Where do I put the above text at & what is dot sourcing and how do I do it? "Keith Hill" wrote: > "Ryan" <Ryan@discussions.microsoft.com> wrote in message > news:0AD68AE5-B901-4E3C-A861-7F5F118D755C@microsoft.com... > > Is there a way I can save cmdlets I have used in previous sessions? i.e. > > I > > want to be able to enter cmdlets I have used in the past after I close and > > restart PowerShell or after I reboot. These would be both for cmdlets I > > have > > written (.ps1 files) & those I have not. > > You can save an entire record of your PowerShell session with the > Start-Transcript cmdlet. If you want certain functions to be part of your > global environment then create a profile (if you doesn't already exist): > > if (!(Test-Path $profile)) { new-item -type file $profile } > notepad $profile > > Then add your functions directly to this file. If you want your profile to > be more modular then you can put your PowerShell function in a PS1 file and > then dot source that file into your profile like so: > > . "$home\My Documents\WindowsPowerShell\funcs.ps1" > > -- > Keith > |
My System Specs![]() |
| | #10 (permalink) |
| Guest | Re: save cmdlets Also, I forgot: I'm a home user, not a programmer or admin, but I do consider myself to be a poweruser. I use XP Home, P4 2.66 w/ 1.5 GB RAM. Not the greatest n the world, but not bad either. "Keith Hill" wrote: > "Ryan" <Ryan@discussions.microsoft.com> wrote in message > news:0AD68AE5-B901-4E3C-A861-7F5F118D755C@microsoft.com... > > Is there a way I can save cmdlets I have used in previous sessions? i.e. > > I > > want to be able to enter cmdlets I have used in the past after I close and > > restart PowerShell or after I reboot. These would be both for cmdlets I > > have > > written (.ps1 files) & those I have not. > > You can save an entire record of your PowerShell session with the > Start-Transcript cmdlet. If you want certain functions to be part of your > global environment then create a profile (if you doesn't already exist): > > if (!(Test-Path $profile)) { new-item -type file $profile } > notepad $profile > > Then add your functions directly to this file. If you want your profile to > be more modular then you can put your PowerShell function in a PS1 file and > then dot source that file into your profile like so: > > . "$home\My Documents\WindowsPowerShell\funcs.ps1" > > -- > Keith > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Save Energy, Save Space in Hard Disk? | vbahamondes | Vista performance & maintenance | 2 | 01-25-2008 12:58 PM |
| Outlook 2007 won't save passwords in Vista...save password box che | Craig | Vista account administration | 10 | 11-16-2007 02:51 PM |
| Open/Save/Save As dialogue shortcuts | @ndyB | Vista General | 9 | 03-16-2007 01:58 PM |
| Programs using Open, Save, Save As functions Stop Responding | Louie1214 | Vista performance & maintenance | 2 | 03-06-2007 12:51 AM |
| Office 2007 hangs on Save and Save As | GlennS | Vista General | 8 | 02-05-2007 12:51 PM |