0

I have a configuration script that I want to run once during an Autopilot install. I've implemented this using the Device Configuration - Powershell scripts. I've turned on transcript and get this output when Intune executes the script

***********************************************
Windows PowerShell transcript start

Start time: 20190411103038

Username: SWIB\OneDrive.Test

RunAs User: SWIB\OneDrive.Test

Configuration Name: 

Machine: L06ALHFSU9YA5NS (Microsoft Windows NT 10.0.17763.0)

Host Application: 
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -executionPolicy bypass -file C:\Program Files (x86)\Microsoft Intune Management Extension\Policies\Scripts\69e660db-d578-4780-9f2e-348c495cd2c3_126e1cef-ade3-4672-a86c-623796621291.ps1

Process ID: 9812

PSVersion: 5.1.17763.134

PSEdition: Desktop

PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.17763.134

BuildVersion: 10.0.17763.134

CLRVersion: 4.0.30319.42000

WSManStackVersion: 3.0

PSRemotingProtocolVersion: 2.3

SerializationVersion: 1.1.0.1

**********************
Transcript started, output file is C:\Temp\SWIB.Install.log
************************

The problem is that when Intune executes the script I get errors that Rename-LocalUser does not exist. But if I run the same script on the same machine using either Powershell or the ISE, the script executes just fine.

++++++++++++++++
Rename-LocalUser : The term 'Rename-LocalUser' 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.
+++++++++++++++++++++++++++

I am wondering what is happening here, it feels like the Powershell process Intune is invoking is different that the one I startup from the command line.

1 Answer 1

0

Sounds like your on an older system and its missing/cant find the Microsoft.PowerShell.LocalAccounts module which contains the Rename-LocalUser cmdlet?

Try adding Import-Module Microsoft.PowerShell.LocalAccounts to your script. Otherwise maybe reinstall Windows Management Framework 5.1.

1
  • Thanks, will try that. This is a 1809 build just in the Autopilot deployment. And, it appears that this module is only not available in the Intune invoked Powershell. Not sure if that describes it, but if when I sign on, I can use the LocalAccounts functions just fine. Thanks very much for this tip.
    – TPL
    Apr 11, 2019 at 21:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .