Skip to content

Commit bf20032

Browse files
committed
updates
1 parent 01032b0 commit bf20032

34 files changed

+1954
-1929
lines changed

.vscode/tasks.json

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
{
2-
// See https://go.microsoft.com/fwlink/?LinkId=733558
3-
// for the documentation about the tasks.json format
4-
"version": "0.1.0",
5-
"isShellCommand": true,
6-
"showOutput": "always",
7-
"tasks":[
8-
{
9-
"taskName": "Copy to test machine",
10-
"command" : "powershell",
11-
"isBuildCommand": true,
12-
"windows":{
13-
"command": "powershell.exe"
14-
},
15-
"args" : [
16-
"-noprofile",
17-
"-command",
18-
".\\.vscode\\UpdateScriptOnTestMachine.ps1 -SourceFile 'C:\\Users\\GLaisne\\OneDrive - Carbonite\\PowerShell\\Carbonite\\ProjectScripts\\ManagedReboot\\ManagedReboot.ps1' -ComputerName '172.30.7.13' -TargetPath 'c$\\Users\\Administrator\\desktop' -Verbose; write-host 'done'"
19-
],
20-
"suppressTaskName": false
21-
},
22-
{
23-
"taskName": "Run script remotely",
24-
"command" : "powershell",
25-
"windows" :{
26-
"command" : "powershell.exe"
27-
},
28-
"args" : [
29-
"-noprofile",
30-
"-command",
31-
"Invoke-Command -ComputerName WIN-UM4FUBJ88UG -Command {c:\\users\\administrator\\desktop\\New-SystemValidationScript.ps1; write-host 'done'} -Credential $([pscredential]::new('Administrator', $(ConvertTo-SecureString -String 'Password!101' -AsPlainText -Force)))"
32-
]
33-
}
34-
]
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "0.1.0",
5+
"isShellCommand": true,
6+
"showOutput": "always",
7+
"tasks":[
8+
{
9+
"taskName": "Copy to test machine",
10+
"command" : "powershell",
11+
"isBuildCommand": true,
12+
"windows":{
13+
"command": "powershell.exe"
14+
},
15+
"args" : [
16+
"-noprofile",
17+
"-command",
18+
".\\.vscode\\UpdateScriptOnTestMachine.ps1 -SourceFile 'C:\\Users\\GLaisne\\OneDrive - Carbonite\\PowerShell\\Carbonite\\ProjectScripts\\ManagedReboot\\ManagedReboot.ps1' -ComputerName '172.30.7.13' -TargetPath 'c$\\Users\\Administrator\\desktop' -Verbose; write-host 'done'"
19+
],
20+
"suppressTaskName": false
21+
},
22+
{
23+
"taskName": "Run script remotely",
24+
"command" : "powershell",
25+
"windows" :{
26+
"command" : "powershell.exe"
27+
},
28+
"args" : [
29+
"-noprofile",
30+
"-command",
31+
"Invoke-Command -ComputerName WIN-UM4FUBJ88UG -Command {c:\\users\\administrator\\desktop\\New-SystemValidationScript.ps1; write-host 'done'} -Credential $([pscredential]::new('Administrator', $(ConvertTo-SecureString -String 'Password!101' -AsPlainText -Force)))"
32+
]
33+
}
34+
]
3535
}

Convert-IPToBinary.ps1

+45-45
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
function Convert-IPToBinary
2-
{
3-
<#
4-
.Synopsis
5-
Converts an IP address string to it's binary string equivalent.
6-
.DESCRIPTION
7-
Takes a IPAddress as a string and returns the same IP address
8-
as a binary string with no decimal points.
9-
.Parameter IPAddress
10-
The IP address which will be converted to a binary string.
11-
.EXAMPLE
12-
Convert-IPToBinary -IPAddress "10.11.12.13"
13-
14-
This example will return
15-
16-
Binary IPAddress
17-
------ ---------
18-
00001010000010110000110000001101 10.11.12.13
19-
#>
20-
[CmdletBinding()]
21-
Param
22-
(
23-
# Param1 help description
24-
[Parameter(Mandatory=$true,
25-
ValueFromPipeline=$true,
26-
Position=0)]
27-
[ValidatePattern("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}")]
28-
[string[]] $IPAddress
29-
)
30-
31-
Begin { }
32-
Process
33-
{
34-
foreach ($IP in $IPAddress)
35-
{
36-
$Binary = ""
37-
$IPAddress.split(".") | %{$Binary = $Binary + $([convert]::toString($_,2).padleft(8,"0"))}
38-
$Result = new-object PSObject -Property @{
39-
IPAddress = $IP
40-
Binary = $Binary
41-
}
42-
Write-Output $Result
43-
}
44-
}
45-
End { }
1+
function Convert-IPToBinary
2+
{
3+
<#
4+
.Synopsis
5+
Converts an IP address string to it's binary string equivalent.
6+
.DESCRIPTION
7+
Takes a IPAddress as a string and returns the same IP address
8+
as a binary string with no decimal points.
9+
.Parameter IPAddress
10+
The IP address which will be converted to a binary string.
11+
.EXAMPLE
12+
Convert-IPToBinary -IPAddress "10.11.12.13"
13+
14+
This example will return
15+
16+
Binary IPAddress
17+
------ ---------
18+
00001010000010110000110000001101 10.11.12.13
19+
#>
20+
[CmdletBinding()]
21+
Param
22+
(
23+
# Param1 help description
24+
[Parameter(Mandatory=$true,
25+
ValueFromPipeline=$true,
26+
Position=0)]
27+
[ValidatePattern("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}")]
28+
[string[]] $IPAddress
29+
)
30+
31+
Begin { }
32+
Process
33+
{
34+
foreach ($IP in $IPAddress)
35+
{
36+
$Binary = ""
37+
$IPAddress.split(".") | %{$Binary = $Binary + $([convert]::toString($_,2).padleft(8,"0"))}
38+
$Result = new-object PSObject -Property @{
39+
IPAddress = $IP
40+
Binary = $Binary
41+
}
42+
Write-Output $Result
43+
}
44+
}
45+
End { }
4646
}

ConvertFrom-SecureString.ps1

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
2-
<#
3-
Taken from https://www.powershelladmin.com/wiki/Powershell_prompt_for_password_convert_securestring_to_plain_text
4-
Date Taken: 12/11/2017
5-
6-
#>
7-
function ConvertFrom-SecureString
8-
{
9-
param(
10-
[Parameter(Mandatory = $true)]
11-
[System.Security.SecureString]
12-
$SecurePassword
13-
)
14-
15-
# Create a "password pointer"
16-
$PasswordPointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword)
17-
18-
# Get the plain text version of the password
19-
$PlainTextPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto($PasswordPointer)
20-
21-
# Free the pointer
22-
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($PasswordPointer)
23-
24-
# Return the plain text password
25-
$PlainTextPassword
26-
27-
}
1+
2+
<#
3+
Taken from https://www.powershelladmin.com/wiki/Powershell_prompt_for_password_convert_securestring_to_plain_text
4+
Date Taken: 12/11/2017
5+
6+
#>
7+
function ConvertFrom-SecureString
8+
{
9+
param(
10+
[Parameter(Mandatory = $true)]
11+
[System.Security.SecureString]
12+
$SecurePassword
13+
)
14+
15+
# Create a "password pointer"
16+
$PasswordPointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecurePassword)
17+
18+
# Get the plain text version of the password
19+
$PlainTextPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto($PasswordPointer)
20+
21+
# Free the pointer
22+
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($PasswordPointer)
23+
24+
# Return the plain text password
25+
$PlainTextPassword
26+
27+
}

ConvertFrom-UnixTime.ps1

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
function ConvertFrom-UnixTime {
2-
<#
3-
.Synopsis
4-
Converts a Unix time into a datetime object.
5-
.DESCRIPTION
6-
Converts a Unix time into a datetime object.
7-
.EXAMPLE
8-
This example converts a Unix Time (int) to standard DateTime object.
9-
10-
ConvertFrom-UnixTime 1000000000
11-
.Link
12-
http://github.com/glaisne/pstools
13-
#>
14-
param(
15-
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
16-
[Int32]
17-
$UnixTime
18-
)
19-
begin {
20-
$startdate = Get-Date –Date '01/01/1970'
21-
}
22-
process {
23-
$timespan = New-Timespan -Seconds $UnixTime
24-
$startdate + $timespan
25-
}
26-
}
27-
1+
function ConvertFrom-UnixTime {
2+
<#
3+
.Synopsis
4+
Converts a Unix time into a datetime object.
5+
.DESCRIPTION
6+
Converts a Unix time into a datetime object.
7+
.EXAMPLE
8+
This example converts a Unix Time (int) to standard DateTime object.
9+
10+
ConvertFrom-UnixTime 1000000000
11+
.Link
12+
http://github.com/glaisne/pstools
13+
#>
14+
param(
15+
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
16+
[Int32]
17+
$UnixTime
18+
)
19+
begin {
20+
$startdate = Get-Date –Date '01/01/1970'
21+
}
22+
process {
23+
$timespan = New-Timespan -Seconds $UnixTime
24+
$startdate + $timespan
25+
}
26+
}
27+

Get-Clear.ps1

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
function Get-Clear () {
2-
3-
$error.Clear()
4-
[gc]::Collect()
5-
cls
6-
}
1+
function Get-Clear () {
2+
3+
$error.Clear()
4+
[gc]::Collect()
5+
cls
6+
}

0 commit comments

Comments
 (0)