Powershell script pushed from Intune>Scripts and Remediations "Failed" with no error code

Dustin H 0 Reputation points
2024-03-22T18:48:11.9766667+00:00

Hello, we have a simple Powershell script to disable SMBv1 that we are pushing to a test Windows 10 device via assignment group. Intune shows that the script has a status of "Failed" with no error code or other detail. Same outcome after rebuilding the script and trying again.

When running the same script as a PS1 file on the device locally, the script runs without issue.

What are the most probable causes of the "Failed" status and the best ways to troubleshoot?

Windows for business Windows Server User experience PowerShell
Microsoft Security Intune Other
{count} votes

4 answers

Sort by: Most helpful
  1. Dominik Hasenkopf 5 Reputation points
    2024-03-24T15:15:01.7966667+00:00

    Hi,

    do you have the script for me?

    it is important that you have an output at the end of the script, e.g.

    Write-Host "ok"
    Exit 0
    
    0 comments No comments

  2. MotoX80 36,291 Reputation points
    2024-03-24T23:39:52.85+00:00

    I do not have any Intune experience, but I would hope that any tool like that could capture the output of the script that you are running. Look for that first.

    When running PS scripts the first place to check is the execution policy.

    https://www.bing.com/search?pglt=41&q=powershell+execution+policy

    If you can't set the policy, add "-executionpolicy bypass" as a command line switch to the PS command.

    What account is the script running as? The system account? Some user account? Is the user a member of the administrators group?

    In your .ps1 file, add a transcript.

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.host/start-transcript?view=powershell-5.1

    If the transcript file does not get created then Intune must not be running the script. Check its logs.

    0 comments No comments

  3. Crystal-MSFT 53,981 Reputation points Microsoft External Staff
    2024-03-25T02:14:27.5266667+00:00

    @Dustin H, Thanks for posting in Q&A. From your description, I know the Remediation script to disable SMBv1 is failed.

    Firstly, please ensure we met the script requirements.

    https://learn.microsoft.com/en-us/mem/intune/fundamentals/remediations#script-requirements

    Secondly, please check what we set for the following settings. Make sure the credential we run the script has enough permission. Meanwhile, please let us know which account you are using to test. Is it a local admin?

    Run this script using the logged-on credentials:

    Enforce script signature check

    Run script in 64-bit PowerShell

    As the Intune Management Extension is response to get the script and tun them. Please ensure the Microsoft Intune Management Extension service is running and check the Intunemanagementextension.log and AgentExcution.log under C:\ProgramData\Microsoft\IntuneManagementExtension\Logs to see if there's any finding.

    https://oliverkieselbach.com/2018/02/12/part-2-deep-dive-microsoft-intune-management-extension-powershell-scripts/

    Note: non-Microsoft link, just for the reference.

    Meanwhile, you can also add your own logging via the start-transcript functionality to troubleshoot the issue if you are familiar with it.

    https://andrewstaylor.com/2022/04/12/proactive-remediations-101-intunes-hidden-secret/

    Note: non-Microsoft link, just for the reference.

    Hope the above information can help.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. Dustin H 0 Reputation points
    2024-03-25T14:27:23.37+00:00

    [posted as comment]

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.