TFS Powershell cmdlet not working in ISE - powershell

I am unable to run the following command in Powershell ISE but these exact same command works just fine in a regular Powershell console.
Get-TfsServer -name http://mytfsserver:8080
I tried adding the Snap-in from the ISE console but it did not help. I even added it to the Script Pane in ISE but it did not help.
I am on Win8 & TFS Power Tools 2012.
Any ideas?

It could be bitness issue. IIRC the TFPT PowerShell module is x86 only. It could be that it is working in an x86 PowerShell console but failing in a 64-bit ISE.

i hope you added pssnapin microsoft.teamfoundation.powershell in to the powershell ISE..
The ISE should be x64 bit. Since this snapin works in x64 bit only.
we dont have any command to check the bitness. but while opening the ISE itself it will show the bitness (if it is x86.)
x64 bit ISE will not show the bitness version.
kudos

Related

PowerShell (x64) stops working after trying to download EXE files (Windows 7)

CONTEXT:
Found a script on SO to download files from URL in PowerShell v2.0 (I am using Windows 7)
PowerShell.exe -ExecutionPolicy Bypass -Command "(New-Object System.Net.WebClient).DownloadFile( 'site.com/file.txt', 'file.txt' )"
Used a batch file .bat to run this script inline.
Works great -- for zip and images!
PROBLEM: Once I try downloading an .exe from URL, the batch file runs WITHOUT executing Powershell script. And Powershell.exe stops working completely in Windows 7...
Powershell (x86) still works, on the other hand.
Opening powershell.exe (x64) directly from folder: C:\WINDOWS\system32\WindowsPowerShell\v1.0 only opens blank window and closes immediately
Tried using sfc /scannow and DISM /Online /Cleanup-image /Restorehealth, but it's not working because Windows 7 doesn't have that option
Running the batch script again works, but the powershell part is skipped
I believe it works again after rebooting (haven't tested properly), but I can't seem to make Powershell (x64) work again without rebooting :/ I don't even know what the problem is as I don't know where to start debugging.
This question might be better suited for superuser.com, but I'm asking here first -- thanks for help :)
As #JCWasmx86 pointed out, it was indeed my Antivirus blocking Powershell.
I tested it extensively with Malwarebytes and Avast in different states -- turned off both of them, then switched them on one by one and ran my script after each state change. Turns out, once Avast got enabled, Powershell (x64, or the default one) got silently blocked after script execution, and persisted inactive until reboot or enough time had passed.
This only happened with .exe files. Avast must not like scripts downloading unverified exe files from the internet.

PowerShell ISE: how to run new PowerShell version

How can I get PowerShell ISE to work with PowerShell 6.0. Currently, it has 4.0.
This server has PowerShell 4.0 installed and I installed PowerShell 6.0 with PowerShell-6.1.0-win-x64.msi from this link: https://github.com/PowerShell/PowerShell/releases
The files now exist in C:\Program Files\PowerShell\6.
However, ISE still shows 4.0, but I need it to run 6.0
$PSVersionTable.psversion
Major Minor Build Revision
4 0 -1 -1
PowerShell has 3 executables...
Windows only...
PowerShell_ISE.exe = ISE v2 - v5.1
powershell.exe = consolehost v1 - 5.1
Note: (there are no new versions coming, but this will be supported going forward as it is today, as per Microsoft announcements, just nothing new coming to it. Just bug /security fixes.)
Cross-platform
pwsh.exe = PowerShell Core/v6
The editor to use if you are using v6 is Visual Studio Code, which is also cross-platform, unlike the ISE.
https://code.visualstudio.com/Download
The are no plans to make the ISE leverage pwsh.exe/PSCore.
However, you can continue to use the ISE, and if you need something specifically to leverage PSCore, you have to shell out to it just as you would to cmd.exe. Your code will run the pwsh.exe console, and return you back to the ISE, depending on how you shell out to it.
What you are using is Windows PowerShell ISE which is always has Windows PowerShell as the integrated shell, you need VSCode here, where you can select which version of PowerShell to use ...
Just need to change below item in File -> Preferences -> Settings.
"terminal.integrated.shell.windows": "C:\\Program Files\\PowerShell\\pwsh.exe"
Same can be done via UI in few clicks as well...

PowerShell IntelliSense targeting older versions of PowerShell

Newer versions of the PowerShell ISE (and third-party PowerShell scripting environments like PowerGUI) offer pretty good IntelliSense support.
However, I often write scripts that I want to run on servers which only have older versions of PowerShell installed (in particular, PowerShell 2.0 on Windows Server 2008 R2). I can't upgrade the PowerShell installation on the server and the PowerShell 2.0 ISE doesn't have IntelliSense.
Is there any way to configure the PowerShell 3.0 or 4.0 ISE, or PowerGUI (or any other free PowerShell script editor!) to provide IntelliSense which is restricted to PowerShell 2.0 compatible code only?
I have confirmed Jason's theory that Intellisense does work in PSRemoting against the installed version of Powershell, but it looks a bit different. I tested using Powershell preview build 5.0.10018.0 remoting to Server 2008R2 with PS v2.0. I ran:
$Procs = Get-Process
$Procs <Ctrl + Space>
This resulted in an Intellisense tooltip with options like:
$Procs.count
$Procs.Clear(
Where v3.0 and up would only include the property or method names, not the variable itself.
I also tested for the .Where() and .Foreach() magic methods which did not show up in Intellisense. This seems to confirm that it's working against the installed version.

Can't use out-gridview since installing PowerGUI with Powershell V3

Just wondering if anyone seen this and knows a workaround.
I'm Running Windows 7 64bit and just upgraded to Powershell V3. Since then, i can't use out-gridview commands. I get the following error.
To use the Out-GridView cmdlet, install the Windows PowerShell Integrated Scripting Environment feature from Server Manager. (Could not load file or assembly '
Microsoft.PowerShell.GraphicalHost, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file sp
ecified.)
I have opened the native MS ISE and can run out-gridview withgout error.
PowerGUI Script Editor launches using PowerShell v.2, even though you have PowerShell v.3 installed. Launching Script Editor with the "-version 3.0" option resolved this problem for me.
There are two things you can check:
When you installed PowerShell V3, did you also make sure to install the PowerShell Integrated Scripting Environment (ISE).
Make sure you have Microsoft .NET Framework v3.5 with Service Pack 1 installed also.
Source of answer
I fixed it by changing -Version 2.0 to -Version 3.0
Right click on Exchange Management shell and choose properties. Find above in TARGET.

Why won't PowerShell ISE let me set breakpoints when running as Administrator?

Having failed to get PowerGUI to work properly I've fallen back on PowerShell ISE. However if I run this as Administrator it won't let me set any breakpoints.
If I launch as normal (my login is a member of Administrators) all is well but because I need to script some tasks that require full administrator rights this is no good.
I have saved the script as a proper file (i.e. it's not "untitled1.ps1") but no joy.
I'm running Windows 7 x64 Ultimate.
Strangely this doesn't seem to be a problem on my Windows 2008 R2 dev box (I'm logging in as user that is a member of Administrators then running PS ISE "As Administrator" and breakpoints are set and hit.
Any ideas why this would be?
I also faced the same issue, saving the file to a physical location enabled all debugging capabilities.
It looks like there's a problem with PowerShell and square brackets in folder and filenames.
Both PowerGUI and PowerShell ISE won't hit breakpoint if the script being debugged resides in a folder with [ or ] in the name.
I notice you're running x64. Is there any chance that you're running x64 ISE but have only set the execution policy away from restricted on x86 (or vice-versa).
I am using Visual Studio Code and in my case, I was missing the powershell extension.
Was facing the same issue because I had used other editor to make changes to the ps1 file. After opening the file with PowerShell ISE and clicking "Save" solved the issue for me.