powershell 清除-AppVO365DocToIdMappingSearchQueries

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 清除-AppVO365DocToIdMappingSearchQueries相关的知识,希望对你有一定的参考价值。

#region Clear-AppVO365DocToIdMappingSearchQueries
function Clear-AppVO365DocToIdMappingSearchQueries {
    [CmdletBinding()]
    PARAM(
        [Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true)]
        [System.Guid[]]
        $PackageId = @("EB51A3D4-B87F-4676-AD01-5D583ABE053C")
        ,
        [switch]
        $Analyze
    )

    begin {
        Write-Verbose $MyInvocation.MyCommand
    }

    process {
        foreach ($Id In $PackageId) {
            Write-Verbose "Id: $($Id)"
            try {
                $SID = (New-Object System.Security.Principal.NTAccount($env:USERNAME)).Translate([System.Security.Principal.SecurityIdentifier]).Value
                Write-Verbose "SID: $($SID)"
                $ProfileNamesRegistryPath = "Registry::HKEY_CURRENT_USER\Software\Microsoft\AppV\Client\Packages\$($Id)\REGISTRY\USER\$($SID)\Software\Microsoft\Office\16.0\Common\Identity\Profiles"
                Write-Verbose "ProfileNamesRegistryPath: $($ProfileNamesRegistryPath)"
                $ProfileNamesRegistryPathExists = Test-Path -Path $ProfileNamesRegistryPath
                Write-Verbose "ProfileNamesRegistryPathExists: $($ProfileNamesRegistryPathExists)"
                if ($ProfileNamesRegistryPathExists -eq $true) {
                    $ProfileNames = Get-ChildItem -Path $ProfileNamesRegistryPath | Where-Object { $_.Name.EndsWith('_ADAL') } | Select-Object -ExpandProperty PSChildName
                    Write-Verbose "ProfileNames: $($ProfileNames -join ',')"
                    foreach ($ProfileName In $ProfileNames) {
                        $Properties = @{
                            PackageId                      = $Id
                            SID                            = $SID
                            ProfileNamesRegistryPath       = $ProfileNamesRegistryPath
                            ProfileNamesRegistryPathExists = $ProfileNamesRegistryPathExists
                            ProfileName                    = $ProfileName
                            ProfileNameRegistryPath        = "Registry::HKEY_CURRENT_USER\Software\Microsoft\AppV\Client\Packages\$($Id)\REGISTRY\USER\$($SID)\Software\Microsoft\Office\16.0\Common\Identity\DocToIdMapping\$($ProfileName)"
                            ProfileNameRegistryPathExists  = $null
                            ItemProperties                 = $null
                            ItemPropertiesCount            = $null
                            Removed                        = $null
                        }
                        $Properties.ProfileNameRegistryPathExists = Test-Path -Path $Properties.ProfileNameRegistryPath
                        if ($Properties.ProfileNameRegistryPathExists) {
                            $Properties.ItemProperties = Get-ItemProperty -Path $Properties.ProfileNameRegistryPath -Name '*&entitytypes=text,people' -ErrorAction SilentlyContinue | Get-Member | Where-Object { $_.MemberType -eq 'NoteProperty' -and $_.Name.EndsWith('&entitytypes=text,people') } | Select-Object -ExpandProperty Name
                            $Properties.ItemPropertiesCount = $Properties.ItemProperties | Measure-Object | Select-Object -ExpandProperty Count
                        }
                        if ($Properties.ItemProperties -and !$Analyze) {
                            try {
                                Remove-ItemProperty -Path $Properties.ProfileNameRegistryPath -Name '*&entitytypes=text,people'
                                $Properties.Removed = $true
                            }
                            catch {
                                $Properties.Removed = $false
                            }
                        }
                        $obj = New-Object -TypeName psobject -Property $Properties
                        Write-Output -InputObject $obj
                    }    
                }
            }
            catch {
                Write-Host $_.Exception.Message
            }
        }
    }

    end {
    }
}
#endregion Clear-AppVO365DocToIdMappingSearchQueries

以上是关于powershell 清除-AppVO365DocToIdMappingSearchQueries的主要内容,如果未能解决你的问题,请参考以下文章

powershell [Manipulandousuários通过PowerShell执行Office 365] Comandos para manipular o Office 365.

powershell [Office 365登录] #PowerShell

使用Powershell链接到Office 365

Powershell RESTAPI 访问Office365

O365 PowerShell Script隔离邮件报告

powershell 批量获取office365用户邮箱使用容量