mirror of
https://github.com/MicrosoftDocs/windows-itpro-docs.git
synced 2025-06-16 02:43:43 +00:00
Merge pull request #10929 from djust270/public
Add helpful PowerShell example Get-AppAUMID
This commit is contained in:
@ -111,3 +111,41 @@ listAumids("CustomerAccount")
|
||||
# Get a list of AUMIDs for all accounts on the device:
|
||||
listAumids("allusers")
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
The following code sample creates a function in Windows PowerShell that returns the AUMID of any application currently listed in the Start menu.
|
||||
|
||||
```powershell
|
||||
function Get-AppAUMID {
|
||||
param (
|
||||
[string]$AppName
|
||||
)
|
||||
$Apps = (New-Object -ComObject Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items()
|
||||
if ($AppName){
|
||||
$Result = $Apps | Where-Object { $_.name -like "*$AppName*" } | Select-Object name,@{n="AUMID";e={$_.path}}
|
||||
if ($Result){
|
||||
Return $Result
|
||||
}
|
||||
else {"Unable to locate {0}" -f $AppName}
|
||||
}
|
||||
else {
|
||||
$Result = $Apps | Select-Object name,@{n="AUMID";e={$_.path}}
|
||||
Return $Result
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The following Windows PowerShell commands demonstrate how you can call the Get-AppAUMID function after you've created it.
|
||||
|
||||
```powershell
|
||||
# Get the AUMID for OneDrive
|
||||
Get-AppAUMID -AppName OneDrive
|
||||
|
||||
# Get the AUMID for Microsoft Word
|
||||
Get-AppAUMID -AppName Word
|
||||
|
||||
# List all apps and their AUMID in the Start menu
|
||||
Get-AppAUMID
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user