diff --git a/MSGraph/MSGraph.psd1 b/MSGraph/MSGraph.psd1 index c40aa7c..c6d1352 100644 --- a/MSGraph/MSGraph.psd1 +++ b/MSGraph/MSGraph.psd1 @@ -3,7 +3,7 @@ RootModule = 'MSGraph.psm1' # Version number of this module. - ModuleVersion = '1.3.0.0' + ModuleVersion = '1.3.0.2' # ID used to uniquely identify this module GUID = '5f61c229-95d0-4423-ab50-938c0723ad21' @@ -179,7 +179,8 @@ ## Attachments 'Save-MgaMailAttachment', - # COre + # Core + 'Connect-MgaGraph', 'Invoke-MgaDeleteMethod' 'Invoke-MgaGetMethod', 'Invoke-MgaPatchMethod', @@ -233,7 +234,7 @@ ProjectUri = 'https://github.com/AndiBellstedt/MSGraph' # A URL to an icon representing this module. - IconUri = 'https://github.com/AndiBellstedt/MSGraph/tree/Development/MSGraph/assets/MSGraph_128x128.png' + IconUri = 'https://github.com/AndiBellstedt/MSGraph/raw/master/assets/MSGraph_128x128.png' # ReleaseNotes of this module ReleaseNotes = 'https://github.com/AndiBellstedt/MSGraph/blob/master/MSGraph/changelog.md' diff --git a/MSGraph/bin/MSGraph.dll b/MSGraph/bin/MSGraph.dll index 712d338..41126ea 100644 Binary files a/MSGraph/bin/MSGraph.dll and b/MSGraph/bin/MSGraph.dll differ diff --git a/MSGraph/bin/MSGraph.pdb b/MSGraph/bin/MSGraph.pdb index aa1ab4b..695076f 100644 Binary files a/MSGraph/bin/MSGraph.pdb and b/MSGraph/bin/MSGraph.pdb differ diff --git a/MSGraph/bin/MSGraph.xml b/MSGraph/bin/MSGraph.xml index ba82473..251d6b4 100644 --- a/MSGraph/bin/MSGraph.xml +++ b/MSGraph/bin/MSGraph.xml @@ -574,9 +574,12 @@ "Issued At" indicates when the authentication for this token occurred. - + - Alias property from Audience + Identifies the issuer, or "authorization server" that constructs and returns the token. + It also identifies the tenant for which the user was authenticated. + If the token was issued by the v2.0 endpoint, the URI ends in /v2.0. + The GUID that indicates that the user is a consumer user from a Microsoft account is 9188040d-6c67-4c5b-b112-36a304b66dad. diff --git a/MSGraph/bin/System.Management.Automation.dll b/MSGraph/bin/System.Management.Automation.dll index 3a17851..9435e86 100644 Binary files a/MSGraph/bin/System.Management.Automation.dll and b/MSGraph/bin/System.Management.Automation.dll differ diff --git a/MSGraph/changelog.md b/MSGraph/changelog.md index 139e4e2..31d1f09 100644 --- a/MSGraph/changelog.md +++ b/MSGraph/changelog.md @@ -1,4 +1,14 @@ # Changelog +## 1.3.0.2 +- Fix: + - Fixing date issue on Mail-Items in PS7 (PS5.1 was working fine) +- Upd: + - Change default permission for New-MgaAccessToken (Connect-MgaGraph)\ + Function is connecting with simple "login" permissions by default. Previously Mail.Read was default. Due to the fact, that there are other functions in the module, this might be a permission not necessary and it would not follow “least-privilege”, the permission was removed +## 1.3.0.1 +- New: Alias Connect-MgaGraph + - Introducing a alias on command New-MgaAccessToken, for convinience +- Fix: Fixing some typos ## 1.3.0.0 - New: Command Get-MgaTeam - returns information about Microsoft Teams team(s) diff --git a/MSGraph/functions/core/Invoke-MgaRestMethodDelete.ps1 b/MSGraph/functions/core/Invoke-MgaRestMethodDelete.ps1 index 5b4fee0..bd41d45 100644 --- a/MSGraph/functions/core/Invoke-MgaRestMethodDelete.ps1 +++ b/MSGraph/functions/core/Invoke-MgaRestMethodDelete.ps1 @@ -105,8 +105,10 @@ try { $data = Invoke-RestMethod @invokeParam -ErrorVariable "restError" -ErrorAction Stop -Verbose:$false -UseBasicParsing } catch { + Remove-Variable -Name invokeParam -Force -WhatIf:$false -Confirm:$false -Verbose:$false -Debug:$false -ErrorAction:SilentlyContinue Stop-PSFFunction -Tag "RestDataError" -Message $_.Exception.Message -Exception $_.Exception -ErrorRecord $_ -EnableException $true -Category ConnectionError -FunctionName $FunctionName } + Remove-Variable -Name invokeParam -Force -WhatIf:$false -Confirm:$false -Verbose:$false -Debug:$false -ErrorAction:SilentlyContinue } if ($data) { diff --git a/MSGraph/functions/core/Invoke-MgaRestMethodGet.ps1 b/MSGraph/functions/core/Invoke-MgaRestMethodGet.ps1 index c7ead08..4d5b6f8 100644 --- a/MSGraph/functions/core/Invoke-MgaRestMethodGet.ps1 +++ b/MSGraph/functions/core/Invoke-MgaRestMethodGet.ps1 @@ -103,7 +103,6 @@ if ($Delta) { $restUri = $restUri + "/delta" } } if ($ResultSize -eq 0) { $ResultSize = [Int64]::MaxValue } - #if ($ResultSize -le 10 -and $restUri -notmatch '\$top=') { $restUri = $restUri + "?`$top=$($ResultSize)" } [Int64]$i = 0 [Int64]$overResult = 0 $tooManyItems = $false @@ -127,8 +126,10 @@ try { $data = Invoke-RestMethod @invokeParam -ErrorVariable "restError" -ErrorAction Stop -Verbose:$false -UseBasicParsing } catch { + Remove-Variable -Name invokeParam -Force -WhatIf:$false -Confirm:$false -Verbose:$false -Debug:$false -ErrorAction:SilentlyContinue Stop-PSFFunction -Tag "RestDataError" -Message $_.Exception.Message -Exception $_.Exception -ErrorRecord $_ -EnableException $true -Category ConnectionError -FunctionName $FunctionName } + Remove-Variable -Name invokeParam -Force -WhatIf:$false -Confirm:$false -Verbose:$false -Debug:$false -ErrorAction:SilentlyContinue if ("Value" -in $data.psobject.Properties.Name) { # Multi object with value property returned by api call @@ -144,7 +145,7 @@ Write-PSFMessage -Tag "ResultSize" -Level Verbose -Message "Resultsize ($ResultSize) exeeded. Output $($overResult) object(s) in record set." } } else { - # Multi object with value property returned by api call + # Single object without value property returned by api call Write-PSFMessage -Tag "RestData" -Level VeryVerbose -Message "Single item retrived. Outputting data." [array]$value = $data $restUri = "" @@ -158,8 +159,7 @@ $output = $output + $Value } } - } - while ($restUri) + } while ($restUri) #endregion query data #region output data diff --git a/MSGraph/functions/core/Invoke-MgaRestMethodPatch.ps1 b/MSGraph/functions/core/Invoke-MgaRestMethodPatch.ps1 index 7248cb8..bb54df7 100644 --- a/MSGraph/functions/core/Invoke-MgaRestMethodPatch.ps1 +++ b/MSGraph/functions/core/Invoke-MgaRestMethodPatch.ps1 @@ -90,8 +90,10 @@ try { $data = Invoke-RestMethod @invokeParam -ErrorVariable "restError" -ErrorAction Stop -Verbose:$false -UseBasicParsing } catch { + Remove-Variable -Name invokeParam -Force -WhatIf:$false -Confirm:$false -Verbose:$false -Debug:$false -ErrorAction:SilentlyContinue Stop-PSFFunction -Tag "RestDataError" -Message $_.Exception.Message -Exception $_.Exception -ErrorRecord $_ -EnableException $true -Category ConnectionError -FunctionName $FunctionName } + Remove-Variable -Name invokeParam -Force -WhatIf:$false -Confirm:$false -Verbose:$false -Debug:$false -ErrorAction:SilentlyContinue if ($data) { $data | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -Force diff --git a/MSGraph/functions/core/Invoke-MgaRestMethodPost.ps1 b/MSGraph/functions/core/Invoke-MgaRestMethodPost.ps1 index f227fdc..a6132e1 100644 --- a/MSGraph/functions/core/Invoke-MgaRestMethodPost.ps1 +++ b/MSGraph/functions/core/Invoke-MgaRestMethodPost.ps1 @@ -91,8 +91,10 @@ try { $data = Invoke-RestMethod @invokeParam -ErrorVariable "restError" -ErrorAction Stop -Verbose:$false -UseBasicParsing } catch { + Remove-Variable -Name invokeParam -Force -WhatIf:$false -Confirm:$false -Verbose:$false -Debug:$false -ErrorAction:SilentlyContinue Stop-PSFFunction -Tag "RestDataError" -Message $_.Exception.Message -Exception $_.Exception -ErrorRecord $_ -EnableException $true -Category ConnectionError -FunctionName $FunctionName } + Remove-Variable -Name invokeParam -Force -WhatIf:$false -Confirm:$false -Verbose:$false -Debug:$false -ErrorAction:SilentlyContinue if ($restError) { Stop-PSFFunction -Tag "RestData" -Message $parseError[0].Exception -Exception $parseError[0].Exception -EnableException $false -Category ConnectionError -FunctionName $FunctionName diff --git a/MSGraph/functions/core/New-MgaAccessToken.ps1 b/MSGraph/functions/core/New-MgaAccessToken.ps1 index 353f53d..16438bf 100644 --- a/MSGraph/functions/core/New-MgaAccessToken.ps1 +++ b/MSGraph/functions/core/New-MgaAccessToken.ps1 @@ -80,6 +80,7 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingConvertToSecureStringWithPlainText", "")] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")] [CmdletBinding(DefaultParameterSetName = "LoginWithWebForm")] + [Alias('Connect-MgaGraph')] param ( [Parameter(ParameterSetName = 'LoginWithCredentialObject')] [PSCredential] @@ -116,6 +117,7 @@ [switch] $PassThru ) + begin { $baselineTimestamp = [datetime]"1970-01-01Z00:00:00" $endpointBaseUri = (Get-PSFConfigValue -FullName MSGraph.Tenant.Authentiation.Endpoint -Fallback 'https://login.microsoftonline.com') @@ -123,17 +125,15 @@ if ($IdentityPlatformVersion -like '1.0' -and $Permission) { Write-PSFMessage -Level Warning -Message "Individual pemissions are not supported in combination with IdentityPlatformVersion 1.0. Specified Permission ($([String]::Join(", ", $Permission))) in parameter will be ignored" -Tag "ParameterSetHandling" $Permission = "" - } elseif ($IdentityPlatformVersion -like '2.0' -and (-not $Permission)) { - $Permission = @("Mail.ReadWrite.Shared") } } process { - # variable definitions + #region variable definitions switch ($IdentityPlatformVersion) { '1.0' { $endpointUri = "$($endpointBaseUri)/$($Tenant)/oauth2" } '2.0' { - if ($Credential -and $Tenant -notlike "organizations") { + if ($Credential -and ($Tenant -notlike "organizations")) { $endpointUri = "$($endpointBaseUri)/organizations/oauth2/V2.0" } else { $endpointUri = "$($endpointBaseUri)/$($Tenant)/oauth2/V2.0" @@ -155,6 +155,8 @@ Remove-Variable -Name scopes -Force -WhatIf:$false -Confirm:$false -Verbose:$false -Debug:$false Write-PSFMessage -Level VeryVerbose -Message "Using scope: $($scope)" -Tag "Authorization" } + #endregion variable definitions + #region Request an authorization code (login procedure) if (-not $Credential) { @@ -180,12 +182,14 @@ } # Show login windows (web form) - $phase1auth = Show-OAuthWindow -Url ($endpointUriAuthorize + (Convert-UriQueryFromHash $queryHash)) + [string]$url = $endpointUriAuthorize + (Convert-UriQueryFromHash $queryHash) + $phase1auth = Show-OAuthWindow -Url $url if (-not $phase1auth.code) { $msg = "Authentication failed. Unable to obtain AccessToken.`n$($phase1auth.error_description)" if ($phase1auth.error) { $msg = $phase1auth.error.ToUpperInvariant() + " - " + $msg } Stop-PSFFunction -Message $msg -Tag "Authorization" -EnableException $true -Exception ([System.Management.Automation.RuntimeException]::new($msg)) } + Remove-Variable -Name url -Force -WhatIf:$false -Confirm:$false -Verbose:$false -Debug:$false # build authorization string with authentication code from web form auth $tokenQueryHash = [ordered]@{ @@ -219,11 +223,11 @@ } #endregion Request an authorization code (login procedure) - # Request an access token - $content = New-Object System.Net.Http.StringContent($authorizationPostRequest, [System.Text.Encoding]::UTF8, "application/x-www-form-urlencoded") + + #region Request an access token + $content = New-Object -TypeName "System.Net.Http.StringContent" -ArgumentList ($authorizationPostRequest, [System.Text.Encoding]::UTF8, "application/x-www-form-urlencoded") $httpClient = New-HttpClient $clientResult = $httpClient.PostAsync([Uri]($endpointUriToken), $content) - $jsonResponse = ConvertFrom-Json -InputObject $clientResult.Result.Content.ReadAsStringAsync().Result -ErrorAction Ignore if ($clientResult.Result.StatusCode -eq [System.Net.HttpStatusCode]"OK") { Write-PSFMessage -Level Verbose -Message "AccessToken granted. $($clientResult.Result.StatusCode.value__) ($($clientResult.Result.StatusCode)) $($clientResult.Result.ReasonPhrase)" -Tag "Authorization" } else { @@ -231,8 +235,12 @@ $msg = "Request for AccessToken failed. $($clientResult.Result.StatusCode.value__) ($($clientResult.Result.StatusCode)) $($clientResult.Result.ReasonPhrase) `n$($jsonResponse.error_description)" Stop-PSFFunction -Message $msg -Tag "Authorization" -EnableException $true -Exception ([System.Management.Automation.RuntimeException]::new($msg)) } + #endregion Request an access token + + + #region Build output object + $jsonResponse = ConvertFrom-Json -InputObject $clientResult.Result.Content.ReadAsStringAsync().Result -ErrorAction Ignore - # Build output object $resultObject = New-Object -TypeName MSGraph.Core.AzureAccessToken -Property @{ IdentityPlatformVersion = $IdentityPlatformVersion TokenType = $jsonResponse.token_type @@ -244,6 +252,7 @@ Resource = $resourceUri AppRedirectUrl = $RedirectUrl } + switch ($IdentityPlatformVersion) { '1.0' { $resultObject.Scope = $jsonResponse.scope -split " " @@ -262,7 +271,9 @@ } # Insert token data into output object. done as secure string to prevent text output of tokens - if ($jsonResponse.psobject.Properties.name -contains "refresh_token") { $resultObject.RefreshToken = ($jsonResponse.refresh_token | ConvertTo-SecureString -AsPlainText -Force) } + if ($jsonResponse.psobject.Properties.name -contains "refresh_token") { + $resultObject.RefreshToken = ($jsonResponse.refresh_token | ConvertTo-SecureString -AsPlainText -Force) + } if ($jsonResponse.psobject.Properties.name -contains "id_token") { $resultObject.IDToken = ($jsonResponse.id_token | ConvertTo-SecureString -AsPlainText -Force) $resultObject.AccessTokenInfo = ConvertFrom-JWTtoken -Token $jsonResponse.id_token @@ -275,13 +286,18 @@ } # Getting validity period out of AccessToken information - if ($resultObject.AccessTokenInfo -and $resultObject.AccessTokenInfo.TenantID.ToString() -notlike "9188040d-6c67-4c5b-b112-36a304b66dad") { + if ($resultObject.AccessTokenInfo -and + ($resultObject.AccessTokenInfo.TenantID.ToString() -notlike "9188040d-6c67-4c5b-b112-36a304b66dad") + ) { $resultObject.ValidUntilUtc = $resultObject.AccessTokenInfo.ExpirationTime.ToUniversalTime() $resultObject.ValidFromUtc = $resultObject.AccessTokenInfo.NotBefore.ToUniversalTime() $resultObject.ValidUntil = $resultObject.AccessTokenInfo.ExpirationTime.ToLocalTime().AddHours( [int]$resultObject.AccessTokenInfo.ExpirationTime.ToLocalTime().IsDaylightSavingTime() ) $resultObject.ValidFrom = $resultObject.AccessTokenInfo.NotBefore.ToLocalTime().AddHours( [int]$resultObject.AccessTokenInfo.NotBefore.ToLocalTime().IsDaylightSavingTime() ) } + #endregion Build output object + + #region Output the object # Checking if token is valid # ToDo implement "validating token information" -> https://docs.microsoft.com/en-us/azure/active-directory/develop/access-tokens#validating-tokens if ($resultObject.IsValid) { @@ -294,5 +310,8 @@ } else { Stop-PSFFunction -Message "Token failure. Acquired token is not valid" -EnableException $true -Tag "Authorization" } + #endregion Output the object } + + end {} } diff --git a/MSGraph/functions/exchange/mail/message/Get-MgaMailMessage.ps1 b/MSGraph/functions/exchange/mail/message/Get-MgaMailMessage.ps1 index c6460bd..7929fe8 100644 --- a/MSGraph/functions/exchange/mail/message/Get-MgaMailMessage.ps1 +++ b/MSGraph/functions/exchange/mail/message/Get-MgaMailMessage.ps1 @@ -109,6 +109,7 @@ [MSGraph.Core.AzureAccessToken] $Token ) + begin { $requiredPermission = "Mail.Read" $Token = Invoke-TokenScopeValidation -Token $Token -Scope $requiredPermission -FunctionName $MyInvocation.MyCommand diff --git a/MSGraph/internal/functions/core/ConvertFrom-JWTtoken.ps1 b/MSGraph/internal/functions/core/ConvertFrom-JWTtoken.ps1 index 36f6787..c552e7a 100644 --- a/MSGraph/internal/functions/core/ConvertFrom-JWTtoken.ps1 +++ b/MSGraph/internal/functions/core/ConvertFrom-JWTtoken.ps1 @@ -51,6 +51,7 @@ $resultObject.Type = $tokenHeaderJSON.typ if ($tokenPayloadJSON.appid) { $resultObject.ApplicationID = $tokenPayloadJSON.appid } $resultObject.ApplicationName = $tokenPayloadJSON.app_displayname + $resultObject.Issuer = $tokenPayloadJSON.iss $resultObject.Audience = $tokenPayloadJSON.aud $resultObject.AuthenticationMethod = $tokenPayloadJSON.amr $resultObject.ExpirationTime = ([datetime]"1970-01-01Z00:00:00").AddSeconds($tokenPayloadJSON.exp).ToUniversalTime() diff --git a/MSGraph/internal/functions/core/Show-OAuthWindow.ps1 b/MSGraph/internal/functions/core/Show-OAuthWindow.ps1 index 6b2bd81..83de8de 100644 --- a/MSGraph/internal/functions/core/Show-OAuthWindow.ps1 +++ b/MSGraph/internal/functions/core/Show-OAuthWindow.ps1 @@ -21,36 +21,67 @@ $Url ) - process { - $web = New-Object -TypeName System.Windows.Forms.WebBrowser -Property @{ - Width = 420 - Height = 600 - Url = $Url + begin {} + + process {} + + end { + # check screen resultion and calculate size for login form + $screenResolution = Get-CimInstance -ClassName Win32_VideoController + $formWidth = [math]::round(($screenResolution.CurrentHorizontalResolution / 4.36), 0) + $formHeight = [math]::round(($screenResolution.CurrentVerticalResolution / 1.69), 0) + if ($formWidth -lt 440) { $formWidth = 440 } + if ($formHeight -lt 640) { $formHeight = 640 } + + # Create form object + $form = New-Object -TypeName "System.Windows.Forms.Form" -Property @{ + Width = $formWidth #440 + Height = $formHeight #640 } - $web.ScriptErrorsSuppressed = $true + + # Create web browser object + $web = New-Object -TypeName "System.Windows.Forms.WebBrowser" -Property @{ + Url = $Url + ClientSize = $form.ClientSize + ScriptErrorsSuppressed = $true + } + + #region Event actions + # parse code or error message from URL, when Login is completed $web.Add_DocumentCompleted( { if ($web.Url.AbsoluteUri -match "error=[^&]*|code=[^&]*") { $form.Close() } - }) + } ) - $form = New-Object -TypeName System.Windows.Forms.Form -Property @{ - Width = 440 - Height = 640 - } - $form.Controls.Add($web) + # Things to do when form is opened/shown $form.Add_Shown( { $form.BringToFront() $null = $form.Focus() $form.Activate() $web.Navigate($Url) - }) + $form.Text = $web.DocumentTitle + } ) + + # make form resizeable + $form.Add_Resize( { + $web.ClientSize = $form.ClientSize + $form.Text = $web.DocumentTitle + } ) + #endregion Event actions + # Add browser to windows form + $form.Controls.Add($web) + + # Show form to the user $null = $form.ShowDialog() + # Get result from uri (query string within the uri) $queryOutput = [System.Web.HttpUtility]::ParseQueryString($web.Url.Query) $output = @{} foreach ($key in $queryOutput.Keys) { $output["$key"] = $queryOutput[$key] } + + # output result [pscustomobject]$output } } \ No newline at end of file diff --git a/MSGraph/internal/functions/exchange/mail/New-MgaMailMessageObject.ps1 b/MSGraph/internal/functions/exchange/mail/New-MgaMailMessageObject.ps1 index 62a6ce6..21e6050 100644 --- a/MSGraph/internal/functions/exchange/mail/New-MgaMailMessageObject.ps1 +++ b/MSGraph/internal/functions/exchange/mail/New-MgaMailMessageObject.ps1 @@ -29,6 +29,41 @@ $FunctionName ) + #region Handle dates + if ($RestData.createdDateTime.psobject.TypeNames[0] -like "System.DateTime") { + $createdDateTime = $RestData.createdDateTime + } else { + $createdDateTime = [datetime]::Parse($RestData.createdDateTime) + } + + if ($RestData.lastModifiedDateTime.psobject.TypeNames[0] -like "System.DateTime") { + $lastModifiedDateTime = $RestData.lastModifiedDateTime + } else { + $lastModifiedDateTime = [datetime]::Parse($RestData.lastModifiedDateTime) + } + + if ($RestData.receivedDateTime.psobject.TypeNames[0] -like "System.DateTime") { + $receivedDateTime = $RestData.receivedDateTime + } else { + if($RestData.receivedDateTime) { + $receivedDateTime = [datetime]::Parse($RestData.receivedDateTime) + } else { + $receivedDateTime = "" + } + } + + if ($RestData.sentDateTime.psobject.TypeNames[0] -like "System.DateTime") { + $sentDateTime = $RestData.sentDateTime + } else { + if($RestData.sentDateTime) { + $sentDateTime = [datetime]::Parse($RestData.sentDateTime) + } else { + $sentDateTime = "" + } + } + + #endregion Handle dates + $hash = [ordered]@{ BaseObject = $RestData Subject = $RestData.subject @@ -37,7 +72,7 @@ Categories = $RestData.categories ChangeKey = $RestData.changeKey ConversationId = $RestData.conversationId - CreatedDateTime = [datetime]::Parse($RestData.createdDateTime) + CreatedDateTime = $createdDateTime Flag = $RestData.flag.flagStatus HasAttachments = $RestData.hasAttachments Id = $RestData.id @@ -48,20 +83,20 @@ IsDraft = $RestData.isDraft IsRead = $RestData.isRead isReadReceiptRequested = $RestData.isReadReceiptRequested - lastModifiedDateTime = [datetime]::Parse($RestData.lastModifiedDateTime) + lastModifiedDateTime = $lastModifiedDateTime MeetingMessageType = $RestData.meetingMessageType ParentFolderId = $RestData.parentFolderId WebLink = $RestData.webLink User = $RestData.User } - if ($RestData.receivedDateTime) { $hash.Add("ReceivedDateTime", [datetime]::Parse($RestData.receivedDateTime)) } - if ($RestData.sentDateTime) { $hash.Add("SentDateTime", [datetime]::Parse($RestData.sentDateTime)) } + if ($RestData.receivedDateTime) { $hash.Add("ReceivedDateTime", $receivedDateTime) } + if ($RestData.sentDateTime) { $hash.Add("SentDateTime", $sentDateTime) } if ($RestData.from.emailAddress) { if ($RestData.from.emailAddress.name -like $RestData.from.emailAddress.address) { # if emailaddress is same in address and in name field, only use address field $from = $RestData.from.emailAddress | ForEach-Object { [mailaddress]$_.address } -ErrorAction Continue } else { - $from = $RestData.from.emailAddress | ForEach-Object { [mailaddress]"$($_.name) $($_.address)"} -ErrorAction Continue + $from = $RestData.from.emailAddress | ForEach-Object { [mailaddress]"$($_.name) $($_.address)" } -ErrorAction Continue } $hash.Add("from", $from) } @@ -70,7 +105,7 @@ # if emailaddress is same in address and in name field, only use address field $senderaddress = $RestData.Sender.emailAddress | ForEach-Object { [mailaddress]$_.address } -ErrorAction Continue } else { - $senderaddress = $RestData.Sender.emailAddress | ForEach-Object { [mailaddress]"$($_.name) $($_.address)"} -ErrorAction Continue + $senderaddress = $RestData.Sender.emailAddress | ForEach-Object { [mailaddress]"$($_.name) $($_.address)" } -ErrorAction Continue } $hash.Add("Sender", $senderaddress) } @@ -79,7 +114,7 @@ # if emailaddress is same in address and in name field, only use address field [array]$bccRecipients = $RestData.bccRecipients.emailAddress | ForEach-Object { [mailaddress]$_.address } -ErrorAction Continue } else { - [array]$bccRecipients = $RestData.bccRecipients.emailAddress | ForEach-Object { [mailaddress]"$($_.name) $($_.address)"} -ErrorAction Continue + [array]$bccRecipients = $RestData.bccRecipients.emailAddress | ForEach-Object { [mailaddress]"$($_.name) $($_.address)" } -ErrorAction Continue } $hash.Add("bccRecipients", [array]$bccRecipients) } @@ -88,7 +123,7 @@ # if emailaddress is same in address and in name field, only use address field [array]$ccRecipients = $RestData.ccRecipients.emailAddress | ForEach-Object { [mailaddress]$_.address } -ErrorAction Continue } else { - [array]$ccRecipients = $RestData.ccRecipients.emailAddress | ForEach-Object { [mailaddress]"$($_.name) $($_.address)"} -ErrorAction Continue + [array]$ccRecipients = $RestData.ccRecipients.emailAddress | ForEach-Object { [mailaddress]"$($_.name) $($_.address)" } -ErrorAction Continue } $hash.Add("ccRecipients", [array]$ccRecipients) } @@ -97,7 +132,7 @@ # if emailaddress is same in address and in name field, only use address field [array]$replyTo = $RestData.replyTo.emailAddress | ForEach-Object { [mailaddress]$_.address } -ErrorAction Continue } else { - [array]$replyTo = $RestData.replyTo.emailAddress | ForEach-Object { [mailaddress]"$($_.name) $($_.address)"} -ErrorAction Continue + [array]$replyTo = $RestData.replyTo.emailAddress | ForEach-Object { [mailaddress]"$($_.name) $($_.address)" } -ErrorAction Continue } $hash.Add("replyTo", [array]$replyTo) } @@ -106,7 +141,7 @@ # if emailaddress is same in address and in name field, only use address field [array]$toRecipients = $RestData.toRecipients.emailAddress | ForEach-Object { [mailaddress]$_.address } -ErrorAction Continue } else { - [array]$toRecipients = $RestData.toRecipients.emailAddress | ForEach-Object { [mailaddress]"$($_.name) $($_.address)"} -ErrorAction Continue + [array]$toRecipients = $RestData.toRecipients.emailAddress | ForEach-Object { [mailaddress]"$($_.name) $($_.address)" } -ErrorAction Continue } $hash.Add("toRecipients", [array]$toRecipients) } diff --git a/build/AzureFunction.readme.md b/build/AzureFunction.readme.md deleted file mode 100644 index 434e135..0000000 --- a/build/AzureFunction.readme.md +++ /dev/null @@ -1,35 +0,0 @@ -# Setting up the release pipeline: - -## Preliminary - -Setting up a release pipeline, set the trigger to do continuous integration against the master branch only. -In Stage 1 set up a tasksequence: - -## 1) PowerShell Task: Prerequisites - -Have it execute `vsts-prerequisites.ps1` - -## 2) PowerShell Task: Validate - -Have it execute `vsts-prerequisites.ps1` - -## 3) PowerShell Task: Build - -Have it execute `vsts-build.ps1`. -The task requires two parameters: - - - `-LocalRepo` - - `-WorkingDirectory $(System.DefaultWorkingDirectory)/_�name�` - -## 4) Publish Test Results - -Configure task to pick up nunit type of tests (rather than the default junit). -Configure task to execute, even if previous steps failed or the task sequence was cancelled. - -## 5) PowerShell Task: Package Function - -Have it execute `vsts-packageFunction.ps1` - -## 6) Azure Function AppDeploy - -Configure to publish to the correct function app. \ No newline at end of file diff --git a/build/azure_pipeline-validate.yml b/build/azure_pipeline-validate.yml index 8868516..e5209a7 100644 --- a/build/azure_pipeline-validate.yml +++ b/build/azure_pipeline-validate.yml @@ -1,5 +1,5 @@ pool: - name: Hosted VS2017 + vmImage: 'windows-latest' # Continuous integration only on branch Development trigger: diff --git a/build/azure_pipeline-validate_and_Build.yml b/build/azure_pipeline-validate_and_Build.yml index 4f671de..fe4ef36 100644 --- a/build/azure_pipeline-validate_and_Build.yml +++ b/build/azure_pipeline-validate_and_Build.yml @@ -1,5 +1,5 @@ pool: - name: Hosted VS2017 + vmImage: 'windows-latest' # Continuous integration only on branch master trigger: diff --git a/build/vsts-createFunctionClientModule.ps1 b/build/vsts-createFunctionClientModule.ps1 deleted file mode 100644 index d7c8d03..0000000 --- a/build/vsts-createFunctionClientModule.ps1 +++ /dev/null @@ -1,205 +0,0 @@ - -<# - .SYNOPSIS - Build script that generates a client module for REST API endpoints of a Azure PowerShell Functions project. - - .DESCRIPTION - Build script that generates a client module for REST API endpoints of a Azure PowerShell Functions project. - - .PARAMETER ApiKey - The API key to use to publish the module to a Nuget Repository - - .PARAMETER WorkingDirectory - The root folder from which to build the module. - - .PARAMETER Repository - The name of the repository to publish to. - Defaults to PSGallery. - - .PARAMETER LocalRepo - Instead of publishing to a gallery, drop a nuget package in the root folder. - This package can then be picked up in a later step for publishing to Azure Artifacts. - - .PARAMETER ParentModule - The actual given name to the module - - .PARAMETER ModuleName - The name to give to the client module. - By default, the client module will be named '.Client'. - - .PARAMETER IncludeFormat - Include the format xml of the source module for the client module. - - .PARAMETER IncludeType - Include the type extension xml of the source module for the client module. - - .PARAMETER IncludeAssembly - Include the binaries of the source module for the client module. -#> -param ( - $ApiKey, - - $WorkingDirectory, - - $Repository = 'PSGallery', - - [switch] - $LocalRepo, - - $ParentModule, - - $ModuleName, - - [switch] - $IncludeFormat, - - [switch] - $IncludeType, - - [switch] - $IncludeAssembly -) - -#region Handle Working Directory Defaults -if (-not $WorkingDirectory) -{ - if ($env:RELEASE_PRIMARYARTIFACTSOURCEALIAS) - { - $WorkingDirectory = Join-Path -Path $env:SYSTEM_DEFAULTWORKINGDIRECTORY -ChildPath $env:RELEASE_PRIMARYARTIFACTSOURCEALIAS - } - else { $WorkingDirectory = $env:SYSTEM_DEFAULTWORKINGDIRECTORY } -} -#endregion Handle Working Directory Defaults - -Write-PSFMessage -Level Host -Message 'Starting Build: Client Module' -if (-not $ModuleName) { $ModuleName = "$($ParentModule).Client" } -Write-PSFMessage -Level Host -Message 'Creating Folder Structure' -$workingRoot = New-Item -Path $WorkingDirectory -Name $ModuleName -ItemType Directory -$publishRoot = Join-Path -Path $WorkingDirectory -ChildPath "publish\$($ParentModule)" -Copy-Item -Path "$($WorkingDirectory)\azFunctionResources\clientModule\functions" -Destination "$($workingRoot.FullName)\" -Recurse -Copy-Item -Path "$($WorkingDirectory)\azFunctionResources\clientModule\internal" -Destination "$($workingRoot.FullName)\" -Recurse -Copy-Item -Path "$($publishRoot)\en-us" -Destination "$($workingRoot.FullName)\" -Recurse -$functionFolder = Get-Item -Path "$($workingRoot.FullName)\functions" - -#region Create Functions -$encoding = [PSFEncoding]'utf8' -$functionsText = Get-Content -Path "$($WorkingDirectory)\azFunctionResources\clientModule\function.ps1" -Raw - -Write-PSFMessage -Level Host -Message 'Creating Functions' -foreach ($functionSourceFile in (Get-ChildItem -Path "$($publishRoot)\functions" -Recurse -Filter '*.ps1')) -{ - Write-PSFMessage -Level Host -Message " Processing function: $($functionSourceFile.BaseName)" - $condensedName = $functionSourceFile.BaseName -replace '-', '' - - #region Load Overrides - $override = @{ } - if (Test-Path -Path "$($WorkingDirectory)\azFunctionResources\functionOverride\$($functionSourceFile.BaseName).psd1") - { - $override = Import-PowerShellDataFile -Path "$($WorkingDirectory)\azFunctionResources\functionOverride\$($functionSourceFile.BaseName).psd1" - } - if (Test-Path -Path "$($WorkingDirectory)\azFunctionResources\functionOverride\$($condensedName).psd1") - { - $override = Import-PowerShellDataFile -Path "$($WorkingDirectory)\azFunctionResources\functionOverride\$($condensedName).psd1" - } - if ($override.NoClientFunction) - { - Write-PSFMessage -Level Host -Message " Override 'NoClientFunction' detected, skipping!" - continue - } - - # If there is an definition override, use it and continue - if (Test-Path -Path "$($WorkingDirectory)\azFunctionResources\functionOverride\$($functionSourceFile.BaseName).ps1") - { - Write-PSFMessage -Level Host -Message " Override function definition detected, using override" - Copy-Item -Path "$($WorkingDirectory)\azFunctionResources\functionOverride\$($functionSourceFile.BaseName).ps1" -Destination $functionFolder.FullName - continue - } - - # Figure out the Rest Method to use - $methodName = 'Post' - if ($override.RestMethods) - { - $methodName = $override.RestMethods | Where-Object { $_ -ne 'Get' } | Select-Object -First 1 - } - - #endregion Load Overrides - - $currentFunctionsText = $functionsText -replace '%functionname%', $functionSourceFile.BaseName -replace '%condensedname%', $condensedName -replace '%method%', $methodName - - $parsedFunction = Read-PSMDScript -Path $functionSourceFile.FullName - $functionAst = $parsedFunction.Ast.EndBlock.Statements | Where-Object { - $_ -is [System.Management.Automation.Language.FunctionDefinitionAst] - } | Select-Object -First 1 - - $end = $functionAst.Body.ParamBlock.Extent.EndOffSet - $start = $functionAst.Body.Extent.StartOffSet + 1 - $currentFunctionsText = $currentFunctionsText.Replace('%parameter%', $functionAst.Body.Extent.Text.SubString(1, ($end - $start))) - - Write-PSFMessage -Level Host -Message " Creating file: $($functionFolder.FullName)\$($functionSourceFile.Name)" - [System.IO.File]::WriteAllText("$($functionFolder.FullName)\$($functionSourceFile.Name)", $currentFunctionsText, $encoding) -} -$functionsToExport = (Get-ChildItem -Path $functionFolder.FullName -Recurse -Filter *.ps1).BaseName | Sort-Object -#endregion Create Functions - -#region Create Core Module Files -# Get Manifest of published version, in order to catch build-phase changes such as module version. -$originalManifestData = Import-PowerShellDataFile -Path "$publishRoot\$($ParentModule).psd1" -$prereqHash = @{ - ModuleName = 'PSFramework' - ModuleVersion = (Get-Module PSFramework).Version -} -$paramNewModuleManifest = @{ - Path = ('{0}\{1}.psd1' -f $workingRoot.FullName, $ModuleName) - FunctionsToExport = $functionsToExport - CompanyName = $originalManifestData.CompanyName - Author = $originalManifestData.Author - Description = $originalManifestData.Description - ModuleVersion = $originalManifestData.ModuleVersion - RootModule = ('{0}.psm1' -f $ModuleName) - Copyright = $originalManifestData.Copyright - TypesToProcess = @() - FormatsToProcess = @() - RequiredAssemblies = @() - RequiredModules = @($prereqHash) - CompatiblePSEditions = 'Core', 'Desktop' - PowerShellVersion = '5.1' -} - -if ($IncludeAssembly) { $paramNewModuleManifest.RequiredAssemblies = $originalManifestData.RequiredAssemblies } -if ($IncludeFormat) { $paramNewModuleManifest.FormatsToProcess = $originalManifestData.FormatsToProcess } -if ($IncludeType) { $paramNewModuleManifest.TypesToProcess = $originalManifestData.TypesToProcess } -Write-PSFMessage -Level Host -Message "Creating Module Manifest for module: $ModuleName" -New-ModuleManifest @paramNewModuleManifest - -Write-PSFMessage -Level Host -Message "Copying additional module files" -Copy-Item -Path "$($WorkingDirectory)\azFunctionResources\clientModule\moduleroot.psm1" -Destination "$($workingRoot.FullName)\$($ModuleName).psm1" -Copy-Item -Path "$($WorkingDirectory)\LICENSE" -Destination "$($workingRoot.FullName)\" -#endregion Create Core Module Files - -#region Transfer Additional Content -if ($IncludeAssembly) -{ - Copy-Item -Path "$publishRoot\bin" -Destination "$($workingRoot.FullName)\" -Recurse -} -if ($IncludeFormat -or $IncludeType) -{ - Copy-Item -Path "$publishRoot\xml" -Destination "$($workingRoot.FullName)\" -Recurse -} -#endregion Transfer Additional Content - -#region Publish -if ($LocalRepo) -{ - # Dependencies must go first - Write-PSFMessage -Level Important -Message "Creating Nuget Package for module: PSFramework" - New-PSMDModuleNugetPackage -ModulePath (Get-Module -Name PSFramework).ModuleBase -PackagePath . -WarningAction SilentlyContinue - Write-PSFMessage -Level Important -Message "Creating Nuget Package for module: $($ParentModule)" - New-PSMDModuleNugetPackage -ModulePath $workingRoot.FullName -PackagePath . -EnableException -} -else -{ - # Publish to Gallery - Write-PSFMessage -Level Important -Message "Publishing the $($ParentModule) module to $($Repository)" - Publish-Module -Path $workingRoot.FullName -NuGetApiKey $ApiKey -Force -Repository $Repository -} -#endregion Publish \ No newline at end of file diff --git a/library/MSGraph/MSGraph/AzureAD/Users/User.cs b/library/MSGraph/MSGraph/AzureAD/Users/User.cs index d97e9a5..c486f7d 100644 --- a/library/MSGraph/MSGraph/AzureAD/Users/User.cs +++ b/library/MSGraph/MSGraph/AzureAD/Users/User.cs @@ -1,9 +1,5 @@ using MSGraph.Exchange.MailboxSetting; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MSGraph.AzureAD.Users { /// diff --git a/library/MSGraph/MSGraph/Core/JWTAccessTokenInfo.cs b/library/MSGraph/MSGraph/Core/JWTAccessTokenInfo.cs index bf0c9ec..832c81a 100644 --- a/library/MSGraph/MSGraph/Core/JWTAccessTokenInfo.cs +++ b/library/MSGraph/MSGraph/Core/JWTAccessTokenInfo.cs @@ -76,16 +76,12 @@ public class JWTAccessTokenInfo { public DateTime IssuedAt; /// - /// Alias property from Audience + /// Identifies the issuer, or "authorization server" that constructs and returns the token. + /// It also identifies the tenant for which the user was authenticated. + /// If the token was issued by the v2.0 endpoint, the URI ends in /v2.0. + /// The GUID that indicates that the user is a consumer user from a Microsoft account is 9188040d-6c67-4c5b-b112-36a304b66dad. /// - public String Issuer { - get { - return Audience; - } - - set { - } - } + public String Issuer; /// /// Provides a human-readable value that identifies the subject of the token. diff --git a/library/MSGraph/MSGraph/Exchange/Attachment/AttachmentParameter.cs b/library/MSGraph/MSGraph/Exchange/Attachment/AttachmentParameter.cs index 791defc..a85bb57 100644 --- a/library/MSGraph/MSGraph/Exchange/Attachment/AttachmentParameter.cs +++ b/library/MSGraph/MSGraph/Exchange/Attachment/AttachmentParameter.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; namespace MSGraph.Exchange.Attachment { /// diff --git a/library/MSGraph/MSGraph/Exchange/Category/CategoryParameter.cs b/library/MSGraph/MSGraph/Exchange/Category/CategoryParameter.cs index 6326545..8c9423b 100644 --- a/library/MSGraph/MSGraph/Exchange/Category/CategoryParameter.cs +++ b/library/MSGraph/MSGraph/Exchange/Category/CategoryParameter.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; namespace MSGraph.Exchange.Category { /// diff --git a/library/MSGraph/MSGraph/Exchange/Category/OutlookCategory.cs b/library/MSGraph/MSGraph/Exchange/Category/OutlookCategory.cs index 8f21988..fb839ae 100644 --- a/library/MSGraph/MSGraph/Exchange/Category/OutlookCategory.cs +++ b/library/MSGraph/MSGraph/Exchange/Category/OutlookCategory.cs @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; namespace MSGraph.Exchange.Category { /// diff --git a/library/MSGraph/MSGraph/Exchange/Mail/MessageParameter.cs b/library/MSGraph/MSGraph/Exchange/Mail/MessageParameter.cs index 54e0274..895e7fd 100644 --- a/library/MSGraph/MSGraph/Exchange/Mail/MessageParameter.cs +++ b/library/MSGraph/MSGraph/Exchange/Mail/MessageParameter.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; namespace MSGraph.Exchange.Mail { /// diff --git a/library/MSGraph/MSGraph/Exchange/MailboxSetting/AutomaticRepliesSetting.cs b/library/MSGraph/MSGraph/Exchange/MailboxSetting/AutomaticRepliesSetting.cs index f07ef0c..f348b47 100644 --- a/library/MSGraph/MSGraph/Exchange/MailboxSetting/AutomaticRepliesSetting.cs +++ b/library/MSGraph/MSGraph/Exchange/MailboxSetting/AutomaticRepliesSetting.cs @@ -1,6 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; namespace MSGraph.Exchange.MailboxSetting { /// diff --git a/library/MSGraph/MSGraph/Exchange/MailboxSetting/LocaleInfoSetting.cs b/library/MSGraph/MSGraph/Exchange/MailboxSetting/LocaleInfoSetting.cs index 70735d8..50449cc 100644 --- a/library/MSGraph/MSGraph/Exchange/MailboxSetting/LocaleInfoSetting.cs +++ b/library/MSGraph/MSGraph/Exchange/MailboxSetting/LocaleInfoSetting.cs @@ -1,6 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; namespace MSGraph.Exchange.MailboxSetting { /// diff --git a/library/MSGraph/MSGraph/Exchange/MailboxSetting/MailboxSettingParameter.cs b/library/MSGraph/MSGraph/Exchange/MailboxSetting/MailboxSettingParameter.cs index 1606d0f..f5f1663 100644 --- a/library/MSGraph/MSGraph/Exchange/MailboxSetting/MailboxSettingParameter.cs +++ b/library/MSGraph/MSGraph/Exchange/MailboxSetting/MailboxSettingParameter.cs @@ -1,6 +1,5 @@ using System; using System.Globalization; -using System.Linq; namespace MSGraph.Exchange.MailboxSetting { /// diff --git a/library/MSGraph/MSGraph/Exchange/MailboxSetting/MailboxSettings.cs b/library/MSGraph/MSGraph/Exchange/MailboxSetting/MailboxSettings.cs index 5156ad4..ef7baf7 100644 --- a/library/MSGraph/MSGraph/Exchange/MailboxSetting/MailboxSettings.cs +++ b/library/MSGraph/MSGraph/Exchange/MailboxSetting/MailboxSettings.cs @@ -1,6 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; namespace MSGraph.Exchange.MailboxSetting { /// diff --git a/library/MSGraph/MSGraph/Exchange/MailboxSetting/WorkingHoursSetting.cs b/library/MSGraph/MSGraph/Exchange/MailboxSetting/WorkingHoursSetting.cs index dbfbe03..64a4651 100644 --- a/library/MSGraph/MSGraph/Exchange/MailboxSetting/WorkingHoursSetting.cs +++ b/library/MSGraph/MSGraph/Exchange/MailboxSetting/WorkingHoursSetting.cs @@ -1,6 +1,4 @@ using System; -using System.Collections; -using System.Collections.Generic; namespace MSGraph.Exchange.MailboxSetting { /// diff --git a/library/MSGraph/MSGraph/Exchange/TimeZoneBase.cs b/library/MSGraph/MSGraph/Exchange/TimeZoneBase.cs index 1c0bf66..8283687 100644 --- a/library/MSGraph/MSGraph/Exchange/TimeZoneBase.cs +++ b/library/MSGraph/MSGraph/Exchange/TimeZoneBase.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MSGraph.Exchange { /// diff --git a/library/MSGraph/MSGraph/Properties/AssemblyInfo.cs b/library/MSGraph/MSGraph/Properties/AssemblyInfo.cs index a6c3645..f9da884 100644 --- a/library/MSGraph/MSGraph/Properties/AssemblyInfo.cs +++ b/library/MSGraph/MSGraph/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MSGraph")] -[assembly: AssemblyCopyright("Copyright © Friedrich Weinmann, Andreas Bellstedt 2018")] +[assembly: AssemblyCopyright("Copyright © 2018 Andreas Bellstedt , Friedrich Weinmann")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.15.1")] -[assembly: AssemblyFileVersion("1.0.15.1")] +[assembly: AssemblyVersion("1.0.16.0")] +[assembly: AssemblyFileVersion("1.0.16.0")]