Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
This is the initial commit of the Azure Migrate Setup Util
  • Loading branch information
steskalja authored Jan 16, 2020
1 parent 1874978 commit 9785e82
Show file tree
Hide file tree
Showing 18 changed files with 17,348 additions and 0 deletions.
5,224 changes: 5,224 additions & 0 deletions AM_Setup/AM_Setup.Package.ps1

Large diffs are not rendered by default.

5,012 changes: 5,012 additions & 0 deletions AM_Setup/AM_Setup.Run.ps1

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions AM_Setup/AM_Setup.psproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Synchronized="False" SyncFilter="*.ps1;*.psm1;*.psd1;*.ps1xml;*.psf;*.pss;*.xml;*.help.txt">
<Version>2.1</Version>
<FileID>aaddbbfb-1591-4905-8d60-3c87a174a6ed</FileID>
<ProjectType>0</ProjectType>
<Folders />
<Files>
<File Build="0">Startup.pss</File>
<File Build="0" Shared="True" ReferenceFunction="Invoke-Global_ps1">Globals.ps1</File>
<File Build="0" ReferenceFunction="Show-MainForm_psf">MainForm.psf</File>
<File Build="2" Shared="True" ReferenceFunction="Invoke-Add-NetAddress_ps1">Add-NetAddress.ps1</File>
<File Build="2" Shared="True" ReferenceFunction="Invoke-Set-Proxy_ps1">Set-Proxy.ps1</File>
<File Build="2" Shared="True" ReferenceFunction="Invoke-Import-Cert_ps1">Import-Cert.ps1</File>
</Files>
</Project>
Binary file added AM_Setup/AM_Setup.psproj.psbuild
Binary file not shown.
13 changes: 13 additions & 0 deletions AM_Setup/AM_Setup.psprojs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<ProjectState>
<Version>1.0</Version>
<FileID>aaddbbfb-1591-4905-8d60-3c87a174a6ed</FileID>
<OpenFolders />
<OpenFiles>
<File>Globals.ps1</File>
<File>Add-NetAddress.ps1</File>
<File>Set-Proxy.ps1</File>
<File>Import-Cert.ps1</File>
<File>MainForm.psf</File>
<File>Startup.pss</File>
</OpenFiles>
</ProjectState>
115 changes: 115 additions & 0 deletions AM_Setup/Add-NetAddress.TempPoint.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2019 v5.6.170
Created on: 12/11/2019 11:24 AM
Created by: 212670239
Organization:
Filename: Add-NetAddress.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>

function Convert-Subnetmask
{
param
(
[parameter(Mandatory = $true)]
[string]
$subnetmask
)
try
{
$netMaskIP = [IPAddress]$subnetmask

$binaryString = [String]::Empty
$netMaskIP.GetAddressBytes() | Foreach {
# combine each
$binaryString += [Convert]::ToString($_, 2)
}

return $binaryString.TrimEnd('0').Length
}
catch
{
return $_
}
}

function Convert-Prefix
{
param
(
[parameter(Mandatory = $true)]
[string]$prefixLength
)
try
{
$bitString = ('1' * $prefixLength).PadRight(32, '0')

$ipString = [String]::Empty

# make 1 string combining a string for each byte and convert to int
for ($i = 0; $i -lt 32; $i += 8)
{
$byteString = $bitString.Substring($i, 8)
$ipString += "$([Convert]::ToInt32($byteString, 2))."
}

return $ipString.TrimEnd('.')
}
catch
{
return $_
}
}

function Set-IPAddress
{
param (
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[string]$Nic,
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[string]$Ipadd,
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[string]$Gw,
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[string]$Sn
)

$rslt = New-NetIPAddress -InterfaceAlias $Nic -IPAddress $Ipadd -DefaultGateway $Gw -PrefixLength $(Convert-Subnetmask $Sn) -ErrorVariable $rslterr
if (!$rslterr)
{
return $rslt
}
else
{
return $rslterr
}

}

function Set-DNS
{
param (
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[string]$Nic,
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[string[]]$DnsAdds
)

$rslt = Set-DnsClientServerAddress -InterfaceAlias $Nic -ServerAddresses $DnsAdds -ErrorVariable $rslterr
if (!$rslterr)
{
return $rslt
}
else
{
return $rslterr
}

}



115 changes: 115 additions & 0 deletions AM_Setup/Add-NetAddress.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2019 v5.6.170
Created on: 12/11/2019 11:24 AM
Created by: 212670239
Organization:
Filename: Add-NetAddress.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>

function Convert-Subnetmask
{
param
(
[parameter(Mandatory = $true)]
[string]
$subnetmask
)
try
{
$netMaskIP = [IPAddress]$subnetmask

$binaryString = [String]::Empty
$netMaskIP.GetAddressBytes() | Foreach {
# combine each
$binaryString += [Convert]::ToString($_, 2)
}

return $binaryString.TrimEnd('0').Length
}
catch
{
return $_
}
}

function Convert-Prefix
{
param
(
[parameter(Mandatory = $true)]
[string]$prefixLength
)
try
{
$bitString = ('1' * $prefixLength).PadRight(32, '0')

$ipString = [String]::Empty

# make 1 string combining a string for each byte and convert to int
for ($i = 0; $i -lt 32; $i += 8)
{
$byteString = $bitString.Substring($i, 8)
$ipString += "$([Convert]::ToInt32($byteString, 2))."
}

return $ipString.TrimEnd('.')
}
catch
{
return $_
}
}

function Set-IPAddress
{
param (
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[string]$Nic,
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[string]$Ipadd,
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[string]$Gw,
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[string]$Sn
)

$rslt = New-NetIPAddress -InterfaceAlias $Nic -IPAddress $Ipadd -DefaultGateway $Gw -PrefixLength $(Convert-Subnetmask $Sn) -ErrorVariable $rslterr
if (!$rslterr)
{
return $rslt
}
else
{
return $rslterr
}

}

function Set-DNS
{
param (
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[string]$Nic,
[Parameter(ValueFromPipeline = $true, Mandatory = $true)]
[string]$DnsAdd
)
[string[]] $DnsAdds = $DnsAdd.Split('|', ',',';')
$rslt = Set-DnsClientServerAddress -InterfaceAlias $Nic -ServerAddresses $DnsAdds -ErrorVariable $rslterr
if (!$rslterr)
{
return $rslt
}
else
{
return $rslterr
}

}



34 changes: 34 additions & 0 deletions AM_Setup/Globals.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#--------------------------------------------
# Declare Global Variables and Functions here
#--------------------------------------------


#Sample function that provides the location of the script
function Get-ScriptDirectory
{
<#
.SYNOPSIS
Get-ScriptDirectory returns the proper location of the script.
.OUTPUTS
System.String
.NOTES
Returns the correct path within a packaged executable.
#>
[OutputType([string])]
param ()
if ($null -ne $hostinvocation)
{
Split-Path $hostinvocation.MyCommand.path
}
else
{
Split-Path $script:MyInvocation.MyCommand.Path
}
}

#Sample variable that provides the location of the script
[string]$ScriptDirectory = Get-ScriptDirectory


92 changes: 92 additions & 0 deletions AM_Setup/Import-Cert.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2019 v5.6.170
Created on: 1/15/2020 10:26 AM
Created by: 212670239
Organization:
Filename: Import-Cert.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>

function Import-Cert
{
param
(
[parameter(Mandatory = $true)]
[string]$certpath,
[parameter(Mandatory = $true)]
[string]$certdst,
[parameter(Mandatory = $true)]
[object[]]$certstores
)
$rslt
try
{
switch ($certdst)
{
'localmachine' {
foreach ($ct in $certstores)
{
switch ($ct)
{
'Personal' {
Import-Certificate -FilePath $certpath -CertStoreLocation cert:\LocalMachine\My
$rslt += "$certpath imported in to cert:\LocalMachine\My `r`n"
break;
}
'Root' {
Import-Certificate -FilePath $certpath -CertStoreLocation cert:\LocalMachine\Root
$rslt += "$certpath imported in to cert:\LocalMachine\Root `r`n"
break;
}
'Intermediate' {
Import-Certificate -FilePath $certpath -CertStoreLocation cert:\LocalMachine\CA
$rslt += "$certpath imported in to cert:\LocalMachine\CA `r`n"
break;
}
}
}

break;
}
'currentuser' {
foreach ($ct in $certstores)
{
switch ($ct)
{
'Personal' {
Import-Certificate -FilePath $certpath -CertStoreLocation cert:\CurrentUser\My
$rslt += "$certpath imported in to cert:\CurrentUser\My `r`n"
break;
}
'Root' {
Import-Certificate -FilePath $certpath -CertStoreLocation cert:\CurrentUser\Root
$rslt += "$certpath imported in to cert:\CurrentUser\Root `r`n"
break;
}
'Intermediate' {
Import-Certificate -FilePath $certpath -CertStoreLocation cert:\CurrentUser\CA
$rslt += "$certpath imported in to cert:\CurrentUser\CA `r`n"
break;
}
}
}
break;
}
default {
$rslt = 'No path Choosen'
break;
}
}
return $rslt
}
catch
{
return $_
}

}

Loading

0 comments on commit 9785e82

Please sign in to comment.