Created
June 12, 2013 14:50
-
-
Save talatham/5765958 to your computer and use it in GitHub Desktop.
Save to a file specified by a user dialog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------ FUNCTION -------------- | |
Function Set-Filename | |
# Set file name for saving export | |
{ | |
[void][System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | |
$SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog | |
$SaveFileDialog.Filter = "Text files (*.txt)|*.txt" | |
$SaveFileDialog.initialDirectory = "c:\" | |
if ($SaveFileDialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) | |
{ $SaveFileDialog.FileName } | |
} | |
# ------ USAGE ------- | |
$filename = Set-FileName | |
"some output text" | out-file $filename - append |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment