Skip to content

Instantly share code, notes, and snippets.

@aetos382
Last active October 28, 2019 06:26
Show Gist options
  • Save aetos382/a993f478f3aed045d5a47991973b6ed0 to your computer and use it in GitHub Desktop.
Save aetos382/a993f478f3aed045d5a47991973b6ed0 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://raw.githubusercontent.com/aetos382/Aerie.PowerShell.Schemas/master/PowerShellFormatDefinitions.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://raw.githubusercontent.com/aetos382/Aerie.PowerShell.Schemas/master/PowerShellFormatDefinitions.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<Configuration>
<ViewDefinitions>
<View>
<Name>PSRepositoryItemInfoTableView</Name>
<ViewSelectedBy>
<TypeName>Microsoft.PowerShell.Commands.PSRepositoryItemInfo</TypeName>
</ViewSelectedBy>
<GroupBy>
<Label>Directory</Label>
<ScriptBlock>
$_.InstalledLocation | Split-Path -Parent | Split-Path -Parent
</ScriptBlock>
</GroupBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Name</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Version</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Scope</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Version</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Scope</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
<?xml version="1.0" encoding="utf-8" ?>
<?xml-model href="https://raw.githubusercontent.com/aetos382/Aerie.PowerShell.Schemas/master/PowerShellTypeDefinitions.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://raw.githubusercontent.com/aetos382/Aerie.PowerShell.Schemas/master/PowerShellTypeDefinitions.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<Types>
<Type>
<Name>Microsoft.PowerShell.Commands.PSRepositoryItemInfo</Name>
<Members>
<ScriptProperty>
<Name>Scope</Name>
<GetScriptBlock>
if (!$this.InstalledLocation) {
return 'Unknown'
}
$IsWindowsPowerShell = $PSVersionTable['PSVersion'].Major -lt 6.0
if ($IsWindowsPowerShell -or $IsWindows) {
if ($IsWindowsPowerShell) {
$productName = 'WindowsPowerShell'
}
else {
$productName = 'PowerShell'
}
($currentUserModulePath, $allusersModulePath) = ([System.Environment]::GetFolderPath('Personal'), $env:ProgramFiles) | Join-Path -ChildPath $productName | Join-Path -ChildPath 'Modules'
}
else {
$currentUserModulePath = [System.Management.Automation.Platform]::SelectProductNameForDirectory('USER_MODULES')
$allUsersModulePath = [System.Management.Automation.Platform]::SelectProductNameForDirectory('SHARED_MODULES')
}
if ($this.InstalledLocation.StartsWith($currentUserModulePath)) {
return 'CurrentUser'
}
elseif ($this.InstalledLocation.StartsWith($allUsersModulePath)) {
return 'AllUsers'
}
return 'Unknown'
</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
</Types>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment