Skip to content

Commit 29b6f05

Browse files
authored
Merge pull request lazywinadmin#20 from sk82jack/remove-aliases
Expand aliases to their full cmdlet/function names
2 parents 32c4af4 + 9ade402 commit 29b6f05

File tree

6 files changed

+33
-33
lines changed

6 files changed

+33
-33
lines changed

SCSM-Get-SCSMUserManager/Get-SCSMUserManager.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
## MAIN
1111
$affectedUser_obj = get-scsmobject -id $input_affectedUser_id
1212
$userManagesUser_relclass_id = '4a807c65-6a1f-15b2-bdf3-e967e58c254a'
13-
$managerOfAffectedUser_relobjs = Get-SCSMRelationshipObject -ByTarget $affectedUser_obj | where{ $_.relationshipId -eq $userManagesUser_relclass_id }
13+
$managerOfAffectedUser_relobjs = Get-SCSMRelationshipObject -ByTarget $affectedUser_obj | Where-Object{ $_.relationshipId -eq $userManagesUser_relclass_id }
1414

1515
## Check if Manager User Exists and that the relationship is current.
1616
## get-scsmrelationshipobject tends to keep track of relationship history. It returns old and new

SCSM-Get-SCSMWorkItemChildItem/Get-SCSMWorkItemChildItem.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
$inputPWI_obj = get-scsmobject -id $inputPWI_guid
1212
$containsActivity_relclass_id = '2da498be-0485-b2b2-d520-6ebd1698e61b'
1313
$childWIs_relobj_filter = "RelationshipId -eq '$containsActivity_relclass_id'"
14-
$childWIs_relobj = Get-SCSMRelationshipObject -BySource $inputPWI_obj | where{ $_.RelationshipId -eq $containsActivity_relclass_id }
14+
$childWIs_relobj = Get-SCSMRelationshipObject -BySource $inputPWI_obj | Where-Object{ $_.RelationshipId -eq $containsActivity_relclass_id }
1515
ForEach ($childWI_relobj in $childWIs_relobj)
1616
{
1717
if ($childWI_relobj.IsDeleted -ne 'false')

TOOL-Invoke-Ping/Invoke-Ping.ps1

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function Invoke-Ping
1+
Function Invoke-Ping
22
{
33
<#
44
.SYNOPSIS
@@ -147,12 +147,12 @@ Function Invoke-Ping
147147
$StandardUserEnv = [powershell]::Create().addscript({
148148

149149
#Get modules and snapins in this clean runspace
150-
$Modules = Get-Module | Select -ExpandProperty Name
151-
$Snapins = Get-PSSnapin | Select -ExpandProperty Name
150+
$Modules = Get-Module | Select-Object -ExpandProperty Name
151+
$Snapins = Get-PSSnapin | Select-Object -ExpandProperty Name
152152

153153
#Get variables in this clean runspace
154154
#Called last to get vars like $? into session
155-
$Variables = Get-Variable | Select -ExpandProperty Name
155+
$Variables = Get-Variable | Select-Object -ExpandProperty Name
156156

157157
#Return a hashtable where we can access each.
158158
@{
@@ -167,22 +167,22 @@ Function Invoke-Ping
167167
#Exclude common parameters, bound parameters, and automatic variables
168168
Function _temp { [cmdletbinding()]
169169
param () }
170-
$VariablesToExclude = @((Get-Command _temp | Select -ExpandProperty parameters).Keys + $PSBoundParameters.Keys + $StandardUserEnv.Variables)
171-
Write-Verbose "Excluding variables $(($VariablesToExclude | sort) -join ", ")"
170+
$VariablesToExclude = @((Get-Command _temp | Select-Object -ExpandProperty parameters).Keys + $PSBoundParameters.Keys + $StandardUserEnv.Variables)
171+
Write-Verbose "Excluding variables $(($VariablesToExclude | Sort-Object) -join ", ")"
172172

173173
# we don't use 'Get-Variable -Exclude', because it uses regexps.
174174
# One of the veriables that we pass is '$?'.
175175
# There could be other variables with such problems.
176176
# Scope 2 required if we move to a real module
177-
$UserVariables = @(Get-Variable | Where { -not ($VariablesToExclude -contains $_.Name) })
178-
Write-Verbose "Found variables to import: $(($UserVariables | Select -expandproperty Name | Sort) -join ", " | Out-String).`n"
177+
$UserVariables = @(Get-Variable | Where-Object { -not ($VariablesToExclude -contains $_.Name) })
178+
Write-Verbose "Found variables to import: $(($UserVariables | Select-Object -expandproperty Name | Sort-Object) -join ", " | Out-String).`n"
179179

180180
}
181181

182182
if ($ImportModules)
183183
{
184-
$UserModules = @(Get-Module | Where { $StandardUserEnv.Modules -notcontains $_.Name -and (Test-Path $_.Path -ErrorAction SilentlyContinue) } | Select -ExpandProperty Path)
185-
$UserSnapins = @(Get-PSSnapin | Select -ExpandProperty Name | Where { $StandardUserEnv.Snapins -notcontains $_ })
184+
$UserModules = @(Get-Module | Where-Object { $StandardUserEnv.Modules -notcontains $_.Name -and (Test-Path $_.Path -ErrorAction SilentlyContinue) } | Select-Object -ExpandProperty Path)
185+
$UserSnapins = @(Get-PSSnapin | Select-Object -ExpandProperty Name | Where-Object { $StandardUserEnv.Snapins -notcontains $_ })
186186
}
187187
}
188188

@@ -220,7 +220,7 @@ Function Invoke-Ping
220220
$runMin = [math]::Round($runtime.totalminutes, 2)
221221

222222
#set up log object
223-
$log = "" | select Date, Action, Runtime, Status, Details
223+
$log = "" | Select-Object Date, Action, Runtime, Status, Details
224224
$log.Action = "Removing:'$($runspace.object)'"
225225
$log.Date = $currentdate
226226
$log.Runtime = "$runMin minutes"
@@ -295,7 +295,7 @@ Function Invoke-Ping
295295

296296
#Clean out unused runspace jobs
297297
$temphash = $runspaces.clone()
298-
$temphash | Where { $_.runspace -eq $Null } | ForEach {
298+
$temphash | Where-Object { $_.runspace -eq $Null } | ForEach-Object {
299299
$Runspaces.remove($_)
300300
}
301301

@@ -345,7 +345,7 @@ Function Invoke-Ping
345345
[void]$list.Add($Ast.SubExpression)
346346
}
347347

348-
$UsingVar = $UsingVariables | Group Parent | ForEach { $_.Group | Select -First 1 }
348+
$UsingVar = $UsingVariables | Group-Object Parent | ForEach-Object { $_.Group | Select-Object -First 1 }
349349

350350
#Extract the name, value, and create replacements for each
351351
$UsingVariableData = ForEach ($Var in $UsingVar)
@@ -440,11 +440,11 @@ Function Invoke-Ping
440440
if ($LogFile)
441441
{
442442
New-Item -ItemType file -path $logFile -force | Out-Null
443-
("" | Select Date, Action, Runtime, Status, Details | ConvertTo-Csv -NoTypeInformation -Delimiter ";")[0] | Out-File $LogFile
443+
("" | Select-Object Date, Action, Runtime, Status, Details | ConvertTo-Csv -NoTypeInformation -Delimiter ";")[0] | Out-File $LogFile
444444
}
445445

446446
#write initial log entry
447-
$log = "" | Select Date, Action, Runtime, Status, Details
447+
$log = "" | Select-Object Date, Action, Runtime, Status, Details
448448
$log.Date = Get-Date
449449
$log.Action = "Batch processing started"
450450
$log.Runtime = $null
@@ -557,7 +557,7 @@ Function Invoke-Ping
557557
#endregion add scripts to runspace pool
558558
}
559559

560-
Write-Verbose ("Finish processing the remaining runspace jobs: {0}" -f (@($runspaces | Where { $_.Runspace -ne $Null }).Count))
560+
Write-Verbose ("Finish processing the remaining runspace jobs: {0}" -f (@($runspaces | Where-Object { $_.Runspace -ne $Null }).Count))
561561
Get-RunspaceData -wait
562562

563563
if (-not $quiet)
@@ -728,7 +728,7 @@ Function Invoke-Ping
728728
{
729729
$DNSEntity = [Net.Dns]::GetHostEntry($name)
730730
$domain = ($DNSEntity.hostname).replace("$name.", "")
731-
$ips = $DNSEntity.AddressList | %{
731+
$ips = $DNSEntity.AddressList | ForEach-Object{
732732
if (-not (-not $IPV6 -and $_.AddressFamily -like "InterNetworkV6"))
733733
{
734734
$_.IPAddressToString
@@ -737,7 +737,7 @@ Function Invoke-Ping
737737
}
738738
catch
739739
{
740-
$rst = New-Object -TypeName PSObject -Property $Hash | Select -Property $props
740+
$rst = New-Object -TypeName PSObject -Property $Hash | Select-Object -Property $props
741741
$rst.name = $name
742742
$results += $rst
743743
$failed = 1
@@ -748,7 +748,7 @@ Function Invoke-Ping
748748
foreach ($ip in $ips)
749749
{
750750

751-
$rst = New-Object -TypeName PSObject -Property $Hash | Select -Property $props
751+
$rst = New-Object -TypeName PSObject -Property $Hash | Select-Object -Property $props
752752
$rst.name = $name
753753
$rst.ip = $ip
754754
$rst.domain = $domain
@@ -832,7 +832,7 @@ Function Invoke-Ping
832832
$w = [wmi] ''
833833
$w.psbase.options.timeout = 15000000
834834
$w.path = "\\$Name\root\cimv2:Win32_ComputerSystem.Name='$Name'"
835-
$w | select none | Out-Null
835+
$w | Select-Object none | Out-Null
836836
$rst.RPC = $true
837837
}
838838
catch
@@ -897,8 +897,8 @@ Function Invoke-Ping
897897
$detail = "WSMan", "RemoteReg", "RPC", "RDP", "SMB"
898898
}
899899

900-
$detail | Select -Unique | Foreach-Object { $TestServerParams.add($_, $True) }
901-
Test-Server @TestServerParams | Select -Property $("Name", "IP", "Domain", "Ping" + $detail)
900+
$detail | Select-Object -Unique | Foreach-Object { $TestServerParams.add($_, $True) }
901+
Test-Server @TestServerParams | Select-Object -Property $("Name", "IP", "Domain", "Ping" + $detail)
902902
}
903903
Catch
904904
{
@@ -914,7 +914,7 @@ Function Invoke-Ping
914914
$result = $null
915915
if ($result = @(Test-Connection -ComputerName $computer -Count 2 -erroraction Stop))
916916
{
917-
$Output = $result | Select -first 1 -Property Address,
917+
$Output = $result | Select-Object -first 1 -Property Address,
918918
IPV4Address,
919919
IPV6Address,
920920
ResponseTime,
@@ -948,7 +948,7 @@ Function Invoke-Ping
948948
$status = "Error: $_"
949949
}
950950

951-
"" | Select -Property @{ label = "Address"; expression = { $computer } },
951+
"" | Select-Object -Property @{ label = "Address"; expression = { $computer } },
952952
IPV4Address,
953953
IPV6Address,
954954
ResponseTime,

TOOL-Out-Excel/Out-Excel.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
$property = @()
4444
if ($raw)
4545
{
46-
$_.properties.PropertyNames | %{ $property += @($_) }
46+
$_.properties.PropertyNames | ForEach-Object{ $property += @($_) }
4747
}
4848
else
4949
{
50-
$_.PsObject.get_properties() | % { $property += @($_.Name.ToString()) }
50+
$_.PsObject.get_properties() | ForEach-Object { $property += @($_.Name.ToString()) }
5151
}
5252
}
5353
$Column = 1

_Profiles/functions/Find-Apartment.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Function Find-Apartment
1+
Function Find-Apartment
22
{
33
<#
44
.SYNOPSIS
@@ -16,7 +16,7 @@ Function Find-Apartment
1616
$AvailableRooms = @()
1717
For ($CurrentPage=0;$CurrentPage -le $MaxPages;$CurrentPage++) {
1818
$WebPage = Invoke-WebRequest "$URL/search/roo?=roo&s=$Start&query=&zoomToPosting=&minAsk=$MinPrice&maxAsk=$MaxPrice&hasPic=1"
19-
$Results = $WebPage.ParsedHtml.body.innerHTML.Split("`n") | ? { $_ -like "<P class=row*" }
19+
$Results = $WebPage.ParsedHtml.body.innerHTML.Split("`n") | Where-Object { $_ -like "<P class=row*" }
2020
ForEach ($Item in $Results) {
2121
$ItemObject=$ID=$Price=$DatePosted=$Neighborhood=$Link=$Description=$Email=$null
2222
$ID = ($Item -replace ".*pid\=`"","") -replace "`".*"
@@ -25,7 +25,7 @@ Function Find-Apartment
2525
$Neighborhood = ($Item -replace ".*\<SMALL\>\(","") -replace "\)\</SMALL>.*"
2626
If ($Neighborhood -like "<*") { $Neighborhood = "N/A" }
2727
$Link = $URL + ((($Item -replace ".*\<A href\=`"","") -replace "\<.*") -split('">'))[0]
28-
$Email = (($(Invoke-WebRequest $Link).ParsedHtml.body.innerHTML.Split("`n") | ? { $_ -like "var displayEmail*" }) -replace "var displayEmail \= `"") -replace "`";"
28+
$Email = (($(Invoke-WebRequest $Link).ParsedHtml.body.innerHTML.Split("`n") | Where-Object { $_ -like "var displayEmail*" }) -replace "var displayEmail \= `"") -replace "`";"
2929
$Description = ((($Item -replace ".*\<A href\=`"","") -replace "\<.*") -split('">'))[1]
3030
$ItemObject = New-Object -TypeName PSObject -Property @{
3131
'ID' = $ID

_Profiles/functions/show-object.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ Add-Type -Assembly System.Windows.Forms
3535
## Figure out the variable name to use when displaying the
3636
## object navigation syntax. To do this, we look through all
3737
## of the variables for the one with the same object identifier.
38-
$rootVariableName = dir variable:\* -Exclude InputObject,Args |
38+
$rootVariableName = Get-ChildItem variable:\* -Exclude InputObject,Args |
3939
Where-Object {
4040
$_.Value -and
4141
($_.Value.GetType() -eq $InputObject.GetType()) -and
4242
($_.Value.GetHashCode() -eq $InputObject.GetHashCode())
4343
}
4444

4545
## If we got multiple, pick the first
46-
$rootVariableName = $rootVariableName| % Name | Select -First 1
46+
$rootVariableName = $rootVariableName| ForEach-Object Name | Select-Object -First 1
4747

4848
## If we didn't find one, use a default name
4949
if(-not $rootVariableName)

0 commit comments

Comments
 (0)