Title: .NET Can't import ActiveDirectory module, works in Powershell · Issue #21232 · PowerShell/PowerShell · GitHub
Open Graph Title: .NET Can't import ActiveDirectory module, works in Powershell · Issue #21232 · PowerShell/PowerShell
X Title: .NET Can't import ActiveDirectory module, works in Powershell · Issue #21232 · 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/21232
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":".NET Can't import ActiveDirectory module, works in Powershell","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://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\n\n### Steps to reproduce\n\nA console app in .NET 8, install Nuget package Microsoft.Powershell.SDK. The code used is:\n\n```\nusing System.Management.Automation.Runspaces;\n...\nvar initial = InitialSessionState.CreateDefault();\ninitial.ExecutionPolicy = Microsoft.PowerShell.ExecutionPolicy.Unrestricted;\n\ninitial.ImportPSModule([\"ActiveDirectory\"]);\nusing var runspace = RunspaceFactory.CreateRunspace(initial);\n\ntry\n{\n runspace.Open();\n}\ncatch(Exception ex)\n{\n Console.WriteLine(ex.ToString());\n}\n```\n\n### Expected behavior\n\n```console\nI would be able to open runspace and use it to run PS commands, since I can run the commands from the Powershell itself.\n```\n\n\n### Actual behavior\n\n```console\nThrows an exception.\n```\n\n\n### Error details\n\n```console\nCould not load file or assembly 'Microsoft.ActiveDirectory.Management, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.\n```\n\n\n### Environment data\n\n```powershell\nName Value \n---- ----- \nPSVersion 5.1.22621.2506 \nPSEdition Desktop \nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} \nBuildVersion 10.0.22621.2506 \nCLRVersion 4.0.30319.42000 \nWSManStackVersion 3.0 \nPSRemotingProtocolVersion 2.3 \nSerializationVersion 1.1.0.1\n```\n\n\n### Visuals\n\n_No response_","author":{"url":"https://github.com/jprpicw","@type":"Person","name":"jprpicw"},"datePublished":"2024-02-15T10:00:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/21232/PowerShell/issues/21232"}
| 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:887fae38-72ac-d16d-31a4-1d713c6d1d94 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A3F8:52373:38E45:49E7A:6A55841C |
| html-safe-nonce | 6eecdda2aeb3a69ab3d7fb1c63c6525dfa0315d85ee6db8d12f969fd93e081a8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0Y4OjUyMzczOjM4RTQ1OjQ5RTdBOjZBNTU4NDFDIiwidmlzaXRvcl9pZCI6IjIyMzM3MDEzOTQ1MTQ1NDM2NDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7c3b36d9503badbf5a8f0a07707e4a84cdbbfa51b11a646881aa6b8f7b73308c |
| hovercard-subject-tag | issue:2136105274 |
| 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/21232/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b99f106cac5664a849d3ba5e2d9d3f7c84f8cb6ee34cf54fee5e2bf7da93a16f/PowerShell/PowerShell/issues/21232 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b99f106cac5664a849d3ba5e2d9d3f7c84f8cb6ee34cf54fee5e2bf7da93a16f/PowerShell/PowerShell/issues/21232 |
| 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 | jprpicw |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| 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 | 3215163789b3dc58dba97bd78a30c20c949f477f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width