I am trying to see if what I am thinking in my head was possible, close to way it is in my head.
Goal: add a function/switch to script(any) that will allow export after displaying results.
Example: run "Get-MsolUser -All -UnlicensedUsersOnly" it displays results. Then to export it I would need to add export "Get-MsolUser -All -UnlicensedUsersOnly | export-csv ***"
Idea: run "Get-MsolUser -All -UnlicensedUsersOnly" then have something added to to display results, then ask/prompt if want to export - if yes then it uses the already pre-planed export ($export = Export-csv ****). If select no, then it ends the script (allowing other scripts to run). Thought of pausing but reviewing results might take a little longer then allotted 30seconds.
Anyone have thoughts or ideas? Anyone do anything like this or see possible issues?
Adding Switch function
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Adding Switch function
There are no functions or switches that will do what you ask. See the examples for the following command.
help Read-Host -online
I suggest starting with this book (free) to get a basic understanding of PowerShell and scripting. It will help you understand how to ask your question.
https://www.sapien.com/books_training/W ... werShell-4
help Read-Host -online
I suggest starting with this book (free) to get a basic understanding of PowerShell and scripting. It will help you understand how to ask your question.
https://www.sapien.com/books_training/W ... werShell-4
Re: Adding Switch function
I have read it but I also know there are ways around certain things or ways to get things to work the way wanted. Also know somethings are not do able. Can't always know the limits unless you ask
Re: Adding Switch function
Not a switch but the out-gridview cmdlet is commonly used for this case. You could write something like this:
The gridview is in and out of support though, based on the PowerShell version and host you're using. You'll need to be sure you can use it in your target deployment before relying on it.
Code: Select all
get-process | out-gridview -PassThru | Export-Csv c:\temp\someprocesses.csv