Input window in power shell is not appearing when script run without opending script editor

rated by 0 users
This post has 4 Replies | 3 Followers

Top 100 Contributor
Posts 38
himanshu Posted: 02-12-2013 8:15 AM

I am asking path from user and getting powershell INPUT window is  prompt when script is open in shell editor

but when I save this script as *.ps1 and right click->run with power shell then it is not showing input window, and suddenly disappears

how to get this INPUT window without opening script in editor

 

#declare paths

$sqlls = Read-Host

($sqlls -eq "quit");

$sqlls =  $sqlls.Trim();

$lxl = "D:\sqlFileList12.xls"

#make a list

ls $sqlls -FILTER *.sql | foreach {$_.name} | OUT-File $lxl -force 

$xl = New-Object -comobject Excel.Application

# Show Excel

$xl.visible = $true

$xl.DisplayAlerts = $False

# Create a workbook

$wb = $xl.Workbooks.open($lxl) 

Top 25 Contributor
Posts 526
Microsoft MVP
Top Contributor

Do you use Windows 7 with PowerShell 3.0?

Top 100 Contributor
Posts 38

windows 7 and shell 2.0, I was fired command Get-Host

Top 25 Contributor
Posts 526
Microsoft MVP
Top Contributor

The recommended way to get a PowerShell version is to use $PSVersionTable automatic variable:

PS> $PSVersionTable

I'm confused that you have "Run with PowerShell" option on a context menu for .ps1 files. That feature is introduced in PowerShell 3.0, and it has a bug on Windows 7 computers.

More details: https://connect.microsoft.com/PowerShell/feedback/details/775161/run-with-powershell-feature-doesnt-work-on-windows-7

 

 

 

Top 100 Contributor
Posts 38

Thanks Aleksandar,

what can I do in this case for a bug, I can't download 3.0 as per company rule, one more thing I have other RDC have sql server 2008 R2 OS x but this code is not opening at all on this os, have no ISE editor, can I do it using CMD

 

Page 1 of 1 (5 items) | RSS
Copyright 2012 PowerShell.com. All rights reserved.