Skip to content

Commit

Permalink
Merge pull request #126 from webmd-health-services/develop
Browse files Browse the repository at this point in the history
Merging develop into master
  • Loading branch information
KhoiKy authored Aug 9, 2022
2 parents 95a3348 + ec4820c commit 8b24247
Show file tree
Hide file tree
Showing 63 changed files with 747 additions and 584 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 2.12.0

* The `Install-CMsi`, `Get-CMsi`, and `Get-CProgramInstallInfo` functions have moved to a new `Carbon.Windows.Installer`
module, now available on the PowerShell Gallery. Please switch to the new module and update usages. If you use these
functions from Carbon, a warning message will be written. These function will be removed in the next major version of
Carbon.
* Carbon now works under PowerShell 7.
* Fixed: Get-CPermission fails to grant permissions on certificates in PowerShell 6+ and on certificates that .NET
Framework load as RSA cryptographic next generation keys, which don't have an API for setting private key permissions.


# 2.11.3

Expand All @@ -9,6 +19,7 @@
* Fixed: `Carbon.Firewall.Rule` type missing the `LocalIP` and `RemoteIP` properties (which are aliases for the
`LocalIpAddress` and `RemoteIPAddress` properties, respectively).


# 2.11.1

* Fixed: Carbon fails to import multiple times in the same session.
Expand Down
2 changes: 1 addition & 1 deletion Carbon/Carbon.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
RootModule = 'Carbon.psm1'

# Version number of this module.
ModuleVersion = '2.11.3'
ModuleVersion = '2.12.0'

# ID used to uniquely identify this module
GUID = '075d9444-c01b-48c3-889a-0b3490716fa2'
Expand Down
146 changes: 131 additions & 15 deletions Carbon/Carbon.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,7 @@ Add-CTypeData -Type Diagnostics.Process `
-MemberType ScriptProperty `
-Value {
$filter = "ProcessID='{0}'" -f $this.Id
if( (Get-Command -Name 'Get-CimInstance' -ErrorAction Ignore) )
{
$process = Get-CimInstance -ClassName 'Win32_Process' -Filter $filter
}
else
{
$process = Get-WmiObject -Class 'Win32_Process' -Filter $filter
}
$process = Invoke-CPrivateCommand -Name 'Get-CCimInstance' -Parameter @{Class = 'Win32_Process'; Filter = $filter}
return $process.ParentProcessID
}

Expand All @@ -212,24 +205,120 @@ Get-ChildItem -Path (Join-Path -Path $functionRoot -ChildPath '*') -Filter '*.ps
. $_.FullName
}

function Write-CWarningOnce
function Write-CObsoleteCommandWarning
{
[CmdletBinding()]
param(
[Parameter(Mandatory,Position=0)]
[String]$Message
[Parameter(Mandatory)]
[String] $CommandName,

[String] $NewCommandName,

[String] $NewModuleName,

[switch] $NewCommandBuiltin
)

Set-StrictMode -Version 'Latest'
Use-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState

$msg = "Carbon's ""$($CommandName)"" function is OBSOLETE and will be removed in the next major version of Carbon."

if( $NewModuleName -and $NewCommandName )
{
$msg = "$($msg) Use the ""$($NewCommandName)"" command in the ""$($ModuleName)"" module instead."
}
elseif( $NewModuleName )
{
$msg = "$($msg) Use commands in the ""$($ModuleName)"" module instead."
}
elseif( $NewCommandName )
{
$builtinMsg = 'the '
if( $NewCommandBuiltin )
{
$builtinMsg = 'PowerShell''s '
}

if( $script:warnings[$Message] )
$msg = "$($msg) Use $($builtinMsg)""$($NewCommandName)"" command instead."
}
else
{
return
$msg = "$($msg) Remove usages."
}

Write-Warning -Message $Message
$script:warnings[$Message] = $true
Write-CWarningOnce -Message $msg
}

function Write-CRefactoredCommandWarning
{
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[String] $CommandName,

[Parameter(Mandatory)]
[String] $ModuleName,

[String] $NewCommandName
)

Set-StrictMode -Version 'Latest'
Use-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState

$msg = "Carbon's ""$($CommandName)"" function MOVED to new ""$($ModuleName)"" module"
if( $NewCommandName )
{
$msg = "$($msg) and renamed ""$($NewCommandName)"""
}

$msg = "$($msg). ""$($CommandName)"" will be removed from the next major version of Carbon. Switch to the new " +
"""$($ModuleName)"" module, available on the PowerShell Gallery."

Write-CWarningOnce -Message $msg
}

function Write-CRenamedCommandWarning
{
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[String] $CommandName,

[Parameter(Mandatory)]
[String] $NewCommandName
)

Set-StrictMode -Version 'Latest'
Use-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState

$msg = "Carbon's ""$($CommandName)"" function RENAMED to ""$($NewCommandName)"". The old ""$($CommandName)"" " +
"function will be removed from the next major version of Carbon. Update usages."
Write-CWarningOnce -Message $msg
}


function Write-CWarningOnce
{
[CmdletBinding()]
param(
[Parameter(Mandatory, Position=0, ParameterSetName='Message', ValueFromPipeline)]
[String] $Message
)

process
{
Set-StrictMode -Version 'Latest'
Use-CallerPreference -Cmdlet $PSCmdlet -SessionState $ExecutionContext.SessionState

if( $script:warnings[$Message] )
{
return
}

Write-Warning -Message $Message
$script:warnings[$Message] = $true
}
}

$developerImports = & {
Expand All @@ -246,4 +335,31 @@ foreach( $developerImport in $developerImports )

Write-Timing ('Dot-sourcing "{0}".' -f $developerImport)
. $developerImport
}

# Allows us to be platform agnostic in our calls of 'GetAccessControl'.
$currentDirInfo = New-Object -TypeName 'IO.DirectoryInfo' -ArgumentList ([Environment]::CurrentDirectory)
if( -not ($currentDirInfo | Get-Member -Name 'GetAccessControl') )
{
Update-TypeData -MemberName 'GetAccessControl' -MemberType 'ScriptMethod' -TypeName 'IO.DirectoryInfo' -Value {
[CmdletBinding()]
param(
[Security.AccessControl.AccessControlSections]$IncludeSections = [Security.AccessControl.AccessControlSections]::All
)

return [IO.FileSystemAclExtensions]::GetAccessControl($this, $IncludeSections)
}
}

$currentCmdInfo = New-Object -TypeName 'IO.FileInfo' -ArgumentList $PSCommandPath
if( -not ($currentCmdInfo | Get-Member -Name 'GetAccessControl') )
{
Update-TypeData -MemberName 'GetAccessControl' -MemberType 'ScriptMethod' -TypeName 'IO.FileInfo' -Value {
[CmdletBinding()]
param(
[Security.AccessControl.AccessControlSections]$IncludeSections = [Security.AccessControl.AccessControlSections]::All
)

return [IO.FileSystemAclExtensions]::GetAccessControl($this, $IncludeSections)
}
}
Loading

0 comments on commit 8b24247

Please sign in to comment.