Skip to content

Commit

Permalink
Minor fixes for better usability
Browse files Browse the repository at this point in the history
  • Loading branch information
swernli committed Dec 17, 2019
1 parent b04484e commit 62fb907
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions WMIv1.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
class wmi {
# Inner CimInstance
[CimInstance] $ciminstance
hidden [CimInstance] $ciminstance

# Path.Path should return underlying Cim Instance for compatibility.
hidden $Path

wmi([CimInstance]$instance) {
$this.ciminstance = $instance
$this.Path = @{"Path" = $this.ciminstance}
$this.Init()
}

Expand All @@ -26,11 +30,6 @@ class wmi {
return "\\$($this.ciminstance.cimsystemproperties.servername)\$($this.ciminstance.cimsystemproperties.namespace.replace("/","\")):$($this.ciminstance.cimsystemproperties.classname).$([string]::Join(",",$keystrings))"
},{}))

# Path.Path should return underlying Cim Instance for compatibility.
$this.psobject.members.Add((new-object management.automation.PSScriptProperty "Path",{
@{"Path"=$this.ciminstance}
},{}))

# Create the default Cim Instance property wrappers.
foreach ($p in $this.ciminstance.CimInstanceProperties){
$this.psobject.members.Add((new-object management.automation.PSScriptProperty `
Expand Down Expand Up @@ -92,6 +91,7 @@ class wmi {
# Refresh the object based on the current cim instance.
Get() {
$this.ciminstance = $this.ciminstance | Get-CimInstance
$this.Path = @{"Path" = [string]$this.ciminstance}
}

[string] GetText($type) {
Expand Down
2 changes: 1 addition & 1 deletion WMIv1.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Get-WmiObject {
[Parameter()]
[ValidateNotNullOrEmpty()]
[string]
$Namespace
$Namespace = "\\.\root\cimv2"
)

if ($Filter.Length -and $Property.Count){
Expand Down
2 changes: 1 addition & 1 deletion test.ps1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docker run --rm -it --isolation process -v "$(Split-Path -Parent $PSCommandPath):c:\project" -w c:\project mcr.microsoft.com/powershell:latest
start docker "run --rm -it --isolation process -v `"$(Split-Path -Parent $PSCommandPath):c:\project`" -w c:\project mcr.microsoft.com/powershell:latest"

0 comments on commit 62fb907

Please sign in to comment.