SOLVED

Commands dont display output when ran in a script

%3CLINGO-SUB%20id%3D%22lingo-sub-2562615%22%20slang%3D%22en-US%22%3ECommands%20dont%20display%20output%20when%20ran%20in%20a%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2562615%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Everyone%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20put%20togeather%20a%20few%20commands%20to%20carry%20out%20a%20maciene%20survey.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEach%20line%20of%20code%20works%20fine%20when%20you%20run%20it%20individually%2C%20however%20when%20it%20runs%20in%20a%20script%20it%20dosnt%20output%20properaly.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2562615%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2563210%22%20slang%3D%22en-US%22%3ERe%3A%20Commands%20dont%20display%20output%20when%20ran%20in%20a%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2563210%22%20slang%3D%22en-US%22%3EWhat%20is%20the%20result%20of%20Get-ExecutionPolicy%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2563262%22%20slang%3D%22en-US%22%3ERe%3A%20Commands%20dont%20display%20output%20when%20ran%20in%20a%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2563262%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F20390%22%20target%3D%22_blank%22%3E%40Andres%20Gorzelany%3C%2FA%3E%3C%2FP%3E%3CP%3Eget-executionpolicy%20returns%26nbsp%3B%3C%2FP%3E%3CP%3ERemoteSigned%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi Everyone 

 

I have put togeather a few commands to carry out a maciene survey.

 

Each line of code works fine when you run it individually, however when it runs in a script it dosnt output properaly. 

 

Any ideas 

5 Replies
What is the result of Get-ExecutionPolicy?

@Andres Gorzelany

get-executionpolicy returns 

RemoteSigned

 

Try to run your .ps1 with an unrestricted execution policy like this

PowerShell.exe -ExecutionPolicy UnRestricted -File .\script.ps1

and see if you got the intended output.

The same issue occurs

best response confirmed by Luke_Gilmore (New Contributor)
Solution
II was able to resolve this issue.

It works fine once i piped the output using format table instead of select object