Pull OnPremisesSyncEnabled status through graph API RRS feed

  • Question

  • Hello all, I have been trying for a couple days as I have time now to connect to graph and pull the
    ###Check for and Install MSGraph
    if (Get-Module -ListAvailable -Name PSMSGraph) 
    { Write-Host "PSMSGraph Already Installed"
    else {
    Install-Module -Name 'PSMSGraph' -Scope CurrentUser
    Import-Module -name 'PSMSGraph' -Scope Local
    ###Check for and Install MSOnline
    if (Get-Module -ListAvailable -Name MSOnline) 
    { Write-Host "MSOnline Already Installed"
    else {
    Install-Module MSOnline -Scope CurrentUser
    Import-Module MSOnline -Scope Local
    $username = "******************"
    $password = "******************"
    $secstr = New-Object -TypeName System.Security.SecureString
    $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
    $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
    $GraphAppParams = @{
    Name = '******************'
    ClientCredential = $Cred
    RedirectUri = 'https://localhost/'
    Tenant = '******************'
    $GraphApp = New-GraphApplication @GraphAppParams
    # This will prompt you to log in with your O365/Azure credentials.
    # This is required at least once to authorize the application to act on behalf of your account
    # The username and password is not passed back to or stored by PowerShell.
    $AuthCode = $GraphApp | Get-GraphOauthAuthorizationCode
    # see the following help for what resource to use.
    # get-help Get-GraphOauthAccessToken -Parameter Resource
    $GraphAccessToken = $AuthCode | Get-GraphOauthAccessToken -Resource ' '
    ####Get User Credentials
    $UserCredential = Get-Credential
    ###Connect to nThrive MSOnline services
    connect-msolservice -Credential $UserCredential
    Function Get-GraphUserInfo {
    $UserLastName = Read-Host -Prompt 'Input the last name of the user you need account information on'
    $userlookupid = get-msoluser -SearchString $UserLastName -all | Out-GridView -PassThru -title "Please select correct user from list" | select-object objectid
    $UserUPN = get-msoluser -ObjectId $userlookupid.ObjectId |  select-object userprincipalname
    Get-AADUserByID -AccessToken $GraphAccessToken -ObjectId $UserUPN.userprincipalname | Select-Object displayname, jobtitle, city, country, Mobile, TelephoneNumber, UserPrincipalName,  Mail, SignInName, ProxyAddresses, AccountEnabled, iscomprimised, deletiontimestamp, assignedlicenses, ImmutableID, objectid, passwordpolicies, physicaldeliveryofficename, state, streetaddress, extension_63f00f8ae3bb4135affd4f2f5cf41ceb_CustomAttribute1,  extension_63f00f8ae3bb4135affd4f2f5cf41ceb_CustomAttribute5, extension_63f00f8ae3bb4135affd4f2f5cf41ceb_CustomAttribute11

    status for all users in the company. I have been able to connect to graph using some other examples found online, and run other commands successfully, but for some reason I cannot seem to find where the above flag is listed in Powershell even though I can see it in Graph Explorer under beta. Below is the script I am using to connect and the working function I have currently. 
    Wednesday, June 5, 2019 1:02 PM