Skip to content

[Issue]: Running BIS-F with Ansible results in: "An error occured while unloading modules: The term 'Write-BISFLog' is not recognized as the name of a cmdlet" #395

Description

@lederer-c

Describe the bug

No matter how i try to start BIS-F via Ansible, it always results in the following error:

fatal: [MASTER]: FAILED! => {"changed": true, "cmd": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy bypass -File \"C:\\Program Files (x86)\\Base Image Script Framework (BIS-F)\\Framework\\PrepBISF_Start.ps1\"", "delta": "0:00:01.148003", "end": "2025-04-25 11:14:13.962275", "msg": "non-zero return code", "rc": 1, "start": "2025-04-25 11:14:12.814271", "stderr": "An error occured while unloading modules. The error is:\r\nThe term 'Write-BISFLog' is not recognized as the name of a cmdlet, function, script file, or \r\noperable program. Check the spelling of the name, or if a path was included, verify that the path \r\nis correct and try again.\r\nAt C:\\Program Files (x86)\\Base Image Script Framework (BIS-F)\\Framework\\PrepBISF_Start.ps1:279 \r\nchar:3\r\n+ Throw \"An error occured while unloading modules. The error is ...\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : OperationStopped: (An error occure... and try again.:String) [], Run \r\n timeException\r\n + FullyQualifiedErrorId : An error occured while unloading modules. The error is:\r\n The term 'Write-BISFLog' is not recognized as the name of a cmdlet, function, script file, or \r\n operable program. Check the spelling of the name, or if a path was included, verify that the p \r\n ath is correct and try again.\r\n \r\n", "stderr_lines": ["An error occured while unloading modules. The error is:", "The term 'Write-BISFLog' 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:\\Program Files (x86)\\Base Image Script Framework (BIS-F)\\Framework\\PrepBISF_Start.ps1:279 ", "char:3", "+ Throw \"An error occured while unloading modules. The error is ...", "+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", " + CategoryInfo : OperationStopped: (An error occure... and try again.:String) [], Run ", " timeException", " + FullyQualifiedErrorId : An error occured while unloading modules. The error is:", " The term 'Write-BISFLog' 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 p ", " ath is correct and try again.", " "], "stdout": "", "stdout_lines": []}

That was my latest attempt, relevant part of the playbook:

  - name: Starte versiegeln mit BIS-F
    win_command:
      argv:
        - powershell.exe
        - -ExecutionPolicy
        - bypass
        - -File
        - C:\Program Files (x86)\Base Image Script Framework (BIS-F)\Framework\PrepBISF_Start.ps1
    become: yes
    become_method: runas
    become_user: DOMAIN\Username
    become_flags: logon_type=interactive logon_flags=with_profile
    register: sealing_result

The very same error comes up when i try to run the "normal" batchfile, although the errormessage is a bit more verbose:

ok: [MASTER] => {
    "msg": {
        "changed": true,
        "cmd": "\"C:\\Program Files (x86)\\Base Image Script Framework (BIS-F)\\PrepareBaseImage.cmd\"",
        "delta": "0:00:02.312786",
        "end": "2025-04-25 11:39:50.087010",
        "failed": false,
        "rc": 0,
        "start": "2025-04-25 11:39:47.774223",
        "stderr": "An error occured while unloading modules. The error is:\r\nThe term 'Write-BISFLog' 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 \r\npath is correct and try again.\r\nAt C:\\Program Files (x86)\\Base Image Script Framework (BIS-F)\\framework\\PrepBISF_Start.ps1:279 char:3\r\n+         Throw \"An error occured while unloading modules. The error is ...\r\n+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n    + CategoryInfo          : OperationStopped: (An error occure... and try again.:String) [], RuntimeException\r\n    + FullyQualifiedErrorId : An error occured while unloading modules. The error is:\r\n    The term 'Write-BISFLog' 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 t \r\n   he path is correct and try again.\r\n \r\n",
        "stderr_lines": [
            "An error occured while unloading modules. The error is:",
            "The term 'Write-BISFLog' 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:\\Program Files (x86)\\Base Image Script Framework (BIS-F)\\framework\\PrepBISF_Start.ps1:279 char:3",
            "+         Throw \"An error occured while unloading modules. The error is ...",
            "+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
            "    + CategoryInfo          : OperationStopped: (An error occure... and try again.:String) [], RuntimeException",
            "    + FullyQualifiedErrorId : An error occured while unloading modules. The error is:",
            "    The term 'Write-BISFLog' 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 t ",
            "   he path is correct and try again.",
            " "
        ],
        "stdout": "initialize script environment... please wait\r\nAdministrative permissions required. Detecting permissions...\r\nSuccess: Administrative permissions confirmed.\r\n",
        "stdout_lines": [
            "initialize script environment... please wait",
            "Administrative permissions required. Detecting permissions...",
            "Success: Administrative permissions confirmed."
        ]
    }
}

Relevant playbook for this run:

  - name: Starte versiegeln mit BIS-F
    win_command:
      argv:
        - C:\Program Files (x86)\Base Image Script Framework (BIS-F)\PrepareBaseImage.cmd
    become: yes
    become_method: runas
    become_user: DOMAIN\Username
    become_flags: logon_type=interactive logon_flags=with_profile
    register: sealing_result

I'm at my wits end with this one, i've tried any combination of "win_command", with and without "chdir" (change execution directory), "become" flags and parameters, so it basically should do the very same thing the link on the desktop does.

Admin-permissions are, as can be seen from the second error output, confirmed - interactive execution does work just fine, as it ever did (thanks for the scripts btw!), i just thought it'd be high time to level up a bit and reduce the amount of manual work needed.

I'd appreciate any pointers i can get!

Steps to reproduce

Run playbook

Expected behavior

Machine should start sealing the base image

Screenshots

No response

Desktop, please complete the following information.

No response

Smartphone, please complete the following information.

No response

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions