microsoft / Partner-Center-PowerShell

PowerShell module for managing Partner Center resources.
https://docs.microsoft.com/powershell/partnercenter/
MIT License
130 stars 59 forks source link

Is the PartnerCenter PowerShell module still maintained? #396

Open mprentice22153 opened 2 years ago

mprentice22153 commented 2 years ago

I'm asking this seriously. Is the module still maintained by anyone?

Looking at the issues that have been opened and closed over the past year, the only closed issues are those closed by GitHub community members. There are numerous open issues that have remained open and some include apparently simple issues to resolve. The PartnerCenter module version is 3.0.10 and was released on July 9, 2020, nearly 2 years ago.

Maybe the module is just so awesome that it hasn't needed an update in 2 years. Maybe the module is outdated and there is a better way for us to get the data and functionality.

Maybe someone with insider knowledge can at least provide some information?

penicaudm commented 2 years ago

As mentioned in the readme:

Partner Center PowerShell is commonly used by partners to manage their Partner Center resources. It is an open source project maintained by the partner community. Since this module is maintained by the partner community, it is not officially supported by Microsoft.

While I don't have insider knowledge, this module has not received attention for a long time and likely will not. It still works for a lot of stuff. I recommend you do not use it and try to move your automation projects to the REST API.

slavizh commented 2 years ago

This module was never officially supported by MSFT. The only maintainers were MSFT employees who stopped maintaining it since they moved outside of MSFT or other teams that are outside of Partner Center area. Move to something else as @penicaudm suggested.

ili101 commented 2 years ago

So "PartnerCenterModule" was deprecated: https://github.com/microsoft/PartnerCenterPowerShellModule

And replaced with "PartnerCenter" that is abandoned: https://github.com/microsoft/Partner-Center-PowerShell

Now you can do some of the stuff by using "MSOnline" but it also deprecated: https://docs.microsoft.com/en-us/powershell/module/msonline/?view=azureadps-1.0

And replaced with "AzureAD" (Azure Active Directory V2) that is deprecated: https://docs.microsoft.com/en-us/powershell/azure/active-directory/overview?view=azureadps-2.0&preserve_view=true

And replaced with "Microsoft.Graph" that can give you 10% of what you need: https://docs.microsoft.com/en-us/powershell/microsoftgraph/overview?view=graph-powershell-1.0

So I see there are a few docs regarding preforming some example operations in C# and REST AP like this : https://docs.microsoft.com/en-us/partner-center/develop/get-customers-of-an-indirect-reseller

I started converting the C# one to PowerShell

Install-Package -Name 'Microsoft.Store.PartnerCenter' -SkipDependencies -Verbose -Scope CurrentUser
Add-Type -Path "$env:LOCALAPPDATA\PackageManagement\NuGet\Packages\Microsoft.Store.PartnerCenter.3.0.1\lib\netstandard2.0\Microsoft.Store.PartnerCenter.dll" -Verbose
Add-Type -Path "$env:LOCALAPPDATA\PackageManagement\NuGet\Packages\Microsoft.Store.PartnerCenter.3.0.1\lib\netstandard2.0\Microsoft.Store.PartnerCenter.Models.dll" -Verbose
Add-Type -Path "$env:LOCALAPPDATA\PackageManagement\NuGet\Packages\Microsoft.Store.PartnerCenter.3.0.1\lib\netstandard2.0\Microsoft.Store.PartnerCenter.Extensions.dll" -Verbose

$partnerOperations = # How to create this? [Microsoft.Store.PartnerCenter.IAggregatePartner]
$indirectResellerId = 'Tenant GUID'

# Create a filter.
$filter = [Microsoft.Store.PartnerCenter.Models.Query.SimpleFieldFilter]::new(
    [Microsoft.Store.PartnerCenter.Models.Customers.CustomerSearchField]::IndirectReseller.ToString(),
    [Microsoft.Store.PartnerCenter.Models.Query.FieldFilterOperation]::StartsWith,
    $indirectResellerId
)
#<# 
# Create an iQuery object to pass to the Query method.
$myQuery = [Microsoft.Store.PartnerCenter.Models.Query.QueryFactory]::Instance.BuildSimpleQuery($filter)

# Get the collection of matching customers.
$customersPage = $partnerOperations.Customers.Query($myQuery);

<# TBD
# Create a customer enumerator for traversing the customer pages.
$customersEnumerator = partnerOperations.Enumerators.Customers.Create(customersPage);
int pageNumber = 1;

while (customersEnumerator.HasValue)
{
    # Work with the current page.
     foreach (var c in customersEnumerator.Current.Items)
    {
        # Display customer tenant identifier and company name.
        Console.WriteLine(string.Format("{0} - {1}.",c.Id,c.CompanyProfile.CompanyName));
    }
    # Get the next page of customers.
    customersEnumerator.Next();
}
#>
}

But I wasn't able to understand how to create the $partnerOperations In this module they create it in here: https://github.com/microsoft/Partner-Center-PowerShell/blob/8fbf3346cf8b86a8214389b29e725efcba14702c/src/PowerShell/Commands/ConnectPartnerCenter.cs#L210 Maybe we can convert this bit of code to PowerShell? or maybe it is possible to simply run Connect-PartnerCenter and extract it from the module context and just use it? Can someone help?

ili101 commented 2 years ago

Are you guys interested in a community maintained PartnerCenter module? Build with native PowerShell + the PartnerCenter dlls. I got almost all the basics already working + 3 cmdlets like Get-PartnerCustomer. The nice thing is that it's pretty simple to implement more of the cmdlets as they all have similar structure and requires only to know PowerShell to write, so if someone need something that is not included he can easily add it and hopefully also submit a PR so we gradually add more of them to the module.

Is there an interest in using or contributing to such module?

mprentice22153 commented 2 years ago

@ili101 I'll admit building a module like this is beyond my programming ability. Rather than re-inventing the wheel can't we expand upon what has already been created as part of this project? Isn't that what GitHub is for? And it looks like there is a new PartnerCenter SDK 3.x that I assume has improvements we need.

As @penicaudm and @slavizh advise, moving directly to the APIs is probably the best answer, and something for me to start digging into.

ili101 commented 2 years ago

@mprentice22153 Freaking Covid finely got to me, so wasn't available. As I said I have working REST and "PS + dlls" working examples, the only core functionality missing is the token refresh for when your script need to run over 3 hours. I can clean it up and share. You raise a good point. the options as I see are:

Advantages Disadvantages
Fork this project (C#) It already exists, just need to update and maintain it. Need people that know and want to maintain a C# project.
PowerShell using dlls Can be maintained and contributed by anyone with PS knowledge. Also need basic classes usage knowledge in PS.
PowerShell using REST Can be maintained and contributed by anyone with PS knowledge. Need to manually handle the API with its oddities.

Examples

https://docs.microsoft.com/en-us/partner-center/develop/get-an-organization-profile

# Get-PartnerOrganizationProfile with the dlls is one line:
$PartnerOperations.Profiles.OrganizationProfile.Get()

# Get-PartnerOrganizationProfile with REST:
$Response = Invoke-RestMethod -ContentType 'application/json;charset=utf-8' -Uri 'https://api.partnercenter.microsoft.com/v1/profiles/organization' -Headers @{
    "Authorization"    = "Bearer " + $AccessToken
    'Accept'           = 'application/json;charset=utf-8'
    'MS-RequestId'     = 'b85cb7ab-cc2e-4966-93f0-cf0d8377a93f'
    'MS-CorrelationId' = '1bb03149-88d2-4bc2-9cc1-d6e83890fa9e'
}
$Response.Substring(1) | ConvertFrom-Json # They put a BOM in it, so strange.

So in assume the easiest solution is to find someone to maintain this module as you mentioned. If not I think that working with the classes is preferable to the API directly as it mitigates some of its weirdness.

mprentice22153 commented 2 years ago

@ili101 Please contact me directly. I'm curious to understand this more and hopefully help with this.

ili101 commented 2 years ago

I took some time to write a readme and made the repo public https://github.com/ili101/PartnerCustomerCommunity. Everyone that wants to help is welcome to open an issue to discuss or contact me. we'll see where things goes.