PowerShell • MS Graph API coding - unable run in Sapien
SAPIEN Forums » PowerShell
by GNS_Licenses
11M ago
I am starting to move away from the soon to be deprecated powershell module for Azure (AZ - ie. connect-msolservice etc) and use the MS Graph API When coding in Sapien Powershell Studio, it doesn't recognise these commands and there's no inline help for this (hover over the command and it states "unknown connect-mggraph"). Is there a way to import the module(s) into Sapien? Using the Powershell ISE works fine so I assume I have to import the commands somehow in to Sapien? Thanks G Statistics: Posted by GNS_Licenses — July 26th, 2023, 4:06 am ..read more
Visit website
PowerShell • Re: Getting different .gettype() on two different Machines
SAPIEN Forums » PowerShell
by Woody_033
11M ago
Thank you Alexander & JVierra for your assistance Statistics: Posted by Woody_033 — July 19th, 2023, 5:52 am ..read more
Visit website
PowerShell • Re: Getting different .gettype() on two different Machines
SAPIEN Forums » PowerShell
by jvierra
11M ago
The pipeline was designed t handle all returns. It can return null, a singularity or a collection. Collections are enumerated into the pipeline. This is the recommended method. Another technique is to "cast" the return to an array. [$mgmtsObjects = [array](Get-WmiObject ....) Now your result will always be of the same type. Statistics: Posted by jvierra — July 19th, 2023, 1:53 am ..read more
Visit website
PowerShell • Re: Getting different .gettype() on two different Machines
SAPIEN Forums » PowerShell
by Alexander Riedel
11M ago
You haven't avoided yet that $PowerOn can have a different type. You cannot simply cast your way out of this. function DoSomething($PowerOnObject) { #process your object } $WMIReturn = Get-WmiObject MSPower_DeviceEnable -Namespace Root\WMI if($WMIReturn.GetType().BaseType -eq [system.Array]) #the returned value is an array of objects { foreach( $PowerOn in $WMIReturn) DoSomething($PowerOn) } else { DoSomething($WMIReturn); # the returned value is the object } This is pseudocode of course. You should still check if each element of the array is the desired type and skip it if not or error out ..read more
Visit website
PowerShell • Re: Getting different .gettype() on two different Machines
SAPIEN Forums » PowerShell
by Woody_033
11M ago
Sorry, I though I had attached it on the first post, I will try again DevicePower.ps1 This is as fare as I got when I got stuck Statistics: Posted by Woody_033 — July 18th, 2023, 9:03 pm ..read more
Visit website
PowerShell • Re: Getting different .gettype() on two different Machines
SAPIEN Forums » PowerShell
by Alexander Riedel
11M ago
Probably means your cast is incorrect. Can you post the complete code? Statistics: Posted by Alexander Riedel — July 18th, 2023, 7:34 pm ..read more
Visit website
PowerShell • Re: Getting different .gettype() on two different Machines
SAPIEN Forums » PowerShell
by Woody_033
11M ago
Untitled.png Computer 1 - Drive 0 - Current OS Computer 1 - Drive 1 - Fresh install (WIP) - [Note] Computer 2 - is a test unit - [Note] [Note]: These 2 installations are practically identical only the hardware is different. dotnet-sdk-6.0.408-win-x64 dotnet-sdk-7.0.302-win-x64 MSChart VC_redist.x64 VC_redist.x86 Code: Write-Debug -Message "Before"; $PowerON.GetType() If ($PowerON.GetType().BaseType -eq [system.Array]) { Write-Debug -Message "PowerON[0]"; $PowerON[0].gettype() } Else {Write-Debug -Message "Else"; $PowerON.GetType() } # as you predicted DEBUG: Before IsPublic IsSerial Name Bas ..read more
Visit website
PowerShell • Re: Getting different .gettype() on two different Machines
SAPIEN Forums » PowerShell
by Alexander Riedel
11M ago
This is actually pretty common for PowerShell to return different types from a cmdlet. If there is only one object to return a cmdlet may only return the object. If there is more than one, the same cmdlet might return a collection. Not knowing what you use to get this return, you may have to code this like (pseudo code) if (type -eq System.Array) object[0].gettype() else object.gettype() to get the desired result. Statistics: Posted by Alexander Riedel — July 18th, 2023, 3:15 pm ..read more
Visit website
PowerShell • Getting different .gettype() on two different Machines
SAPIEN Forums » PowerShell
by Woody_033
11M ago
Product: PowerShell Studio 2023 (64 Bit) Build: v5.8.225 OS: Windows 10 Pro (64 Bit) Build: v10.0.19045.0 I have the same script on two Machines DevicePower.ps1 One Machine it gives me: Code: IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Object[] System.Array ..read more
Visit website
PowerShell • Re: How to change a path for output file MSI in PSBUILD
SAPIEN Forums » PowerShell
by RISFRANCE
1y ago
Hmm, how stupid of me x) I just found what I needed For other users, if you're looking for the same thing, select files and folders on the right and scroll down to find the following "output folder" items. Statistics: Posted by RISFRANCE — July 7th, 2023, 9:41 am ..read more
Visit website

Follow SAPIEN Forums » PowerShell on FeedSpot

Continue with Google
Continue with Apple
OR