Hello RiteshSharma,
It would be very helpful if you could explain how it fails or add text or screenshot of the returned error.
In the meantime, I can recommend to add installation for NuGet packageprovider, as it will be required to run Get-WindowsAutoPilotInfo
You can see the syntax here: https://learn.microsoft.com/en-us/powershell/module/packagemanagement/install-packageprovider?view=powershell-7.2#example-2-install-a-specified-version-of-a-package-provider
----------------------------------------------------------------------------------------------------------------------------------
--If the reply is helpful, please Upvote and Accept as answer--