Title: Import-Module with UseWindowsPowerShell parameter as LOCALSYSTEM account fails if $HOME\Documents\Powershell\Modules directory does not exist. · Issue #17744 · PowerShell/PowerShell · GitHub
Open Graph Title: Import-Module with UseWindowsPowerShell parameter as LOCALSYSTEM account fails if $HOME\Documents\Powershell\Modules directory does not exist. · Issue #17744 · PowerShell/PowerShell
X Title: Import-Module with UseWindowsPowerShell parameter as LOCALSYSTEM account fails if $HOME\Documents\Powershell\Modules directory does not exist. · Issue #17744 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/17744
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Import-Module with UseWindowsPowerShell parameter as LOCALSYSTEM account fails if $HOME\\Documents\\Powershell\\Modules directory does not exist.","articleBody":"### Prerequisites\n\n- [X] Write a descriptive title.\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\n- [X] Search the existing issues.\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://docs.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\n\n### Steps to reproduce\n\nWe have a Windows Service that runs as LOCALSYSTEM that uses the PowerShell SDK to periodically run pwsh commands. The calls to import modules with the UseWindowsPowershell parameter are failing. \r\n\r\nI was able to narrow the down the scope of the repro steps to what I have below. I used the ActiveDirectory module as my example to import, but we are also seeing this behavior on other modules we import with the UseWindowsPowershell parameter. \r\n\r\n1. Open pwsh as LOCAL SYSTEM Account. (I used `psexec -s -i pwsh.exe` from a command prompt on a test machine).\r\n2. Run `Import-Module ActiveDirectory -UseWindowsPowerShell`. If you don't have the ActiveDirectory module installed, see here: https://docs.microsoft.com/en-us/powershell/module/activedirectory/?view=windowsserver2022-ps. I've also found running this command will produce the same results,` Import-Module Microsoft.Powershell.Management -UseWindowsPowerShell -NoClobber`\r\n3. Import-Module fails.\r\n\r\n4. Message logged to the PowerShell Core Operational Event logs is misleading as it seems to indicate it failed to create module in c:\\windows\\temp folder.\r\n\r\n\r\n\r\nWORKAROUND:\r\n1. Close the pwsh window. \r\n2. Create the directory: c:\\windows\\system32\\config\\systemprofile\\documents\\powershell\\modules. C:\\windows\\system32\\config\\systemprofile is the $HOME folder for the LOCAL SYSTEM account. \r\n3. Open pwsh as LOCAL SYSTEM Account (I used `psexec -s -i pwsh.exe `from a command prompt).\r\n4. Run `Import-Module ActiveDirectory -UseWindowsPowerShell `\r\n5. ActiveDirectory module successfully imports.\r\n\r\n\n\n### Expected behavior\n\n```console\nModule is successfully imported.\n```\n\n\n### Actual behavior\n\n```console\nModule is not imported and a failure message is returned.\n```\n\n\n### Error details\n\n```console\nImport-Module: Failed to generate proxies for remote module 'ActiveDirectory'. The -OutputModule parameter does not resolve to a path, and a user module path cannot be found for the provided name.\n```\n\n\n### Environment data\n\n```powershell\nName Value\r\n---- -----\r\nPSVersion 7.2.5\r\nPSEdition Core\r\nGitCommitId 7.2.5\r\nOS Microsoft Windows 10.0.17763\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\n```\n\n\n### Visuals\n\n_No response_","author":{"url":"https://github.com/cmichaelingram","@type":"Person","name":"cmichaelingram"},"datePublished":"2022-07-22T18:03:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/17744/PowerShell/issues/17744"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4cc2a56a-8930-ecff-24ab-f9acd9dbb692 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C06A:186D37:CC1A32:114F0BD:6A59390C |
| html-safe-nonce | 7e1446e5a9d2aa4daca811ae7017cc3eadc013a15db0a7d58d6c8b5ecfddd0b6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDZBOjE4NkQzNzpDQzFBMzI6MTE0RjBCRDo2QTU5MzkwQyIsInZpc2l0b3JfaWQiOiI4MTQ3MTMxNjE3NDE0NTYwMDEyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c7e543dfc73d6b7edb737d05fc61548cb7d7ea352d714e9bc442dc73947f9335 |
| hovercard-subject-tag | issue:1315283179 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/17744/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e76c5f4157829b174b71b0a6f796dbe5d5e982e54e986584e07821b9fcf8449b/PowerShell/PowerShell/issues/17744 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e76c5f4157829b174b71b0a6f796dbe5d5e982e54e986584e07821b9fcf8449b/PowerShell/PowerShell/issues/17744 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cmichaelingram |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1b31c9453e1607b2781513084b4770f67217e549834c85b76960d7b13626f7c8 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 220f27779da5b92b5e17fcaef93e474cc8affba3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width