Quantcast
Channel: Azure Active Directory forum
Viewing all articles
Browse latest Browse all 16000

Pull OnPremisesSyncEnabled status through graph API

$
0
0
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 MSGraphif(Get-Module-ListAvailable-NamePSMSGraph){Write-Host"PSMSGraph Already Installed"}else{Install-Module-Name'PSMSGraph'-ScopeCurrentUserImport-Module-name 'PSMSGraph'-ScopeLocal}###Check for and Install MSOnlineif(Get-Module-ListAvailable-NameMSOnline){Write-Host"MSOnline Already Installed"}else{Install-ModuleMSOnline-ScopeCurrentUserImport-ModuleMSOnline-ScopeLocal}

$username ="******************"
$password ="******************"
$secstr =New-Object-TypeNameSystem.Security.SecureString
$password.ToCharArray()|ForEach-Object{$secstr.AppendChar($_)}
$cred =new-object-typenameSystem.Management.Automation.PSCredential-argumentlist $username, $secstr


$GraphAppParams =@{Name='******************'ClientCredential= $CredRedirectUri='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'https://graph.windows.net '####Get User Credentials

$UserCredential =Get-Credential###Connect to nThrive MSOnline services

connect-msolservice -Credential $UserCredentialFunctionGet-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 userprincipalnameGet-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. 

Viewing all articles
Browse latest Browse all 16000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>