CrowdStrike / psfalcon

PowerShell for CrowdStrike's OAuth2 APIs
The Unlicense
350 stars 66 forks source link

[ BUG ] `Write-Result not recognized` when using `Request-FalconToken` #388

Closed mcj323s closed 5 months ago

mcj323s commented 6 months ago

Describe the bug Error in the oauth2.ps1 file in the module. Script is being run on a multi-tenant environment.

To Reproduce

Request-FalconToken -ClientId <ClientId> -ClientSecret <ClientSecret> -Cloud us-1 -MemberCID <MemberCID>
Write-Result : The term 'Write-Result' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\owner\My Documents\WindowsPowerShell\Modules\PSFalcon\2.2.6\public\oauth2.ps1:187 char:23 
+             $Result = Write-Result (ConvertFrom-Json (
+                       ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Write-Result:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
bk-cs commented 6 months ago

It sounds like your module was not properly installed, or some of the internal functions did not import properly.

Did you use this exact Install-Module command during installation?

Install-Module -Name PSFalcon -Scope CurrentUser

Once installed, did you properly Import-Module before running commands?

Import-Module -Name PSFalcon

I recommend a full re-install before retrying:

Uninstall-Module -Name PSFalcon -AllVersions
Install-Module -Name PSFalcon -Scope CurrentUser
Import-Module -Name PSFalcon
Request-FalconToken -ClientId ... -ClientSecret ...
bk-cs commented 6 months ago

@mcj323s Did any of those steps help with your issue? Is this still a problem?

mcj323s commented 6 months ago

I am having the issues after reinstall.

mcj323s commented 6 months ago

I am not sure if this has to do with running it from version 5.1 of powershell. I have tried running this script on a different system as well.

bk-cs commented 6 months ago

Write-Result is an internal function that PSFalcon uses to select the proper output after a request is made. It's loaded with all the other private functions when you Import-Module. For the specific function to not load is very strange, unless there's something different about your machine that is preventing the loading.

PowerShell 5.1 is the standard version used for all PSFalcon development, and the most commonly used version by PSFalcon users. I don't have any other reports of this sort of issue, and any similar issues that have come up in the past have been due to something during install or import that is breaking the PSFalcon installation.

bk-cs commented 6 months ago

Please let me know if your issues are resolved. I will close this issue in the next few business days if I do not hear back. Thanks!