Azure-Samples / Azure-Samples/azure-files-samples
AzFilesHybrid Powershell Module - PSRemote session cannot run the module
- Dominant language
- PowerShell
- Stars
- 261
- Forks
- 202
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 4
Description
We are trying to automate the [Azure File share Domain join](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fazure%2Fstorage%2Ffiles%2Fstorage-files-identity-ad-ds-enable&data=05%7C01%7Caaneddame%40microsoft.com%7C02d5e918bd0242d9ac0b08dacd9620f7%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638048342582176579%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Hvuj76ajpY9F7131NtJCRfNsiaVwcjKl3otJm%2F0XIVI%3D&reserved=0), using Azure YML Pipelines.
We are currently hitting an issue with the AzFilesHybrid PowerShell [Module](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure-Samples%2Fazure-files-samples%2Freleases&data=05%7C01%7Caaneddame%40microsoft.com%7C02d5e918bd0242d9ac0b08dacd9620f7%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638048342582176579%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=wh4BswYMykx6%2Fh%2F9Ox3Nh5f01jgq2GyGo7qCiIA9MOI%3D&reserved=0), when running the command: Join-AzStorageaccountForAuth from either a PS remote session or through the ADO task: PowershellonTargetMachine@3 (Same error).
PS: We have tested the module directly inside the VM, and it is working.
The error is the following:


We have identified that the following command: Get-ADDomain, from the line 2398 of the module, is failing (Same error above) from a PS Remote Session, but when we use “-server “ parameter, if you run the command (Get-ADDomain) from a PS Remote Session, it works. (At least this is what we have found during our troubleshooting)
• When we run the command with -server from PSRemoteSession:
Invoke-Command -Session $s -ScriptBlock {Get-ADDomain -server -Credential domain\admin}: **working**
• When we run the command without -server from PSRemoteSession:
Invoke-Command -Session $s -ScriptBlock {Get-ADDomain -Credential domain\admin} : **not working**
• When we run the module from VM Hybrid Worker: **working**
PS: All prerequisites needed to run the module as well as WinRM are valid and available in the VM.
Could you please help me explain this behavior, as well as any alternatives / workaround for this issue, (as updating the module would not be an option) ?
Contributor guide
Assessment
This issue has not been assessed yet.