Skip to content

Instantly share code, notes, and snippets.

$FileList = (Get-ChildItem 'C:\Users\Dern\Desktop\DNSSCAN\Batchtest').fullname
$c1 = 0
$lineamount =
$m = Get-Content -Path $FileList | Measure-Object -line
@($m).lines
$myOutput = @() # Declare empty array
param (
$domainname = (
"testmappe.dk",
"testmappe2.dk"
),
$fullremotepathdelete = $remotepathsdelete,
$fileNameDelete = "*",
@Jonatantwn
Jonatantwn / downloadmultiple.ps1
Last active April 15, 2020 16:18
A method to download specific files from different folders, using powershell and WinSCP
param (
$localPath = "C:\Users\Dern\Desktop\WINSCP PS DOWNLOAD\",
$remotePath = ("jonatantest/","jonatantest2/"),
$fileName = "wp-config-sample.php"
)
try
{
# Load WinSCP .NET assembly
Add-Type -Path "C:\Users\Dern\Desktop\WINSCP PS\WinSCPnet.dll"
param (
$localPath = "C:\Users\Dern\Desktop\WINSCP PS DOWNLOAD\",
$remotePath = ("jonatantest/","jonatantest2/"),
$fileName = "wp-config-sample.php"
)
try
{
# Load WinSCP .NET assembly
Add-Type -Path "C:\Users\Dern\Desktop\WINSCP PS\WinSCPnet.dll"
@Jonatantwn
Jonatantwn / gist:fddf201995cee75f26b14a9590cf1b2a
Created April 15, 2020 11:27
download and rename files with powershell
param (
$localPath = "C:\Users\Dern\Desktop\WINSCP PS DOWNLOAD\",
$remotePath = "jonatantest/",
$fileName = "wp-config-sample.php"
)
try
{
# Load WinSCP .NET assembly
Add-Type -Path "C:\Users\Dern\Desktop\WINSCP PS\WinSCPnet.dll"
$FileList = (Get-ChildItem 'C:\Users\Dern\Desktop\Searchtarget\searchtargetlist.txt').fullname
foreach ($FileName in $FileList) {
try
{
# Load WinSCP .NET assembly
Add-Type -Path "C:\Users\Dern\Desktop\WINSCP PS\WinSCPnet.dll"
@Jonatantwn
Jonatantwn / gist:55428c3c2cd08191009ebe51a6586a94
Created April 6, 2020 13:01
Delete files Powershell WINSCP
try
{
# Load WinSCP .NET assembly
Add-Type -Path "C:\Users\Dern\Desktop\WINSCP PS\WinSCPnet.dll"
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::ftp
HostName = "xxx"
UserName = "xx.dk"
try
{
# Load WinSCP .NET assembly
Add-Type -Path "C:\Users\Dern\Desktop\WINSCP PS\WinSCPnet.dll"
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::ftp
HostName = "xxxxxxxxxxxxx.com"
UserName = "xxx.dk"
$FileList = (Get-ChildItem 'C:\Users\jonat\Desktop\DNS PROCCESSING\Batchtest\*.txt').fullname
$myOutput = @() # Declare empty array
foreach ($FileName in $FileList) {
$myOutput += foreach ($DomainName in (Get-Content $FileName)) {
try {
$NSRecords = Resolve-DnsName $DomainName -Type NS -EA 1 | Where-Object { $_.QueryType -eq 'NS' }
$DomainFinal = (Invoke-WebRequest -Uri $DomainName -UseBasicParsing).BaseResponse.ResponseUri.AbsoluteUri -replace "https://" -replace "http://" -replace "www." -replace ".dk/", ".dk" -replace ".com/", ".com"
[PSCustomObject]@{
Resolved = $true
$FileList = (Get-ChildItem 'C:\Users\jonat\Desktop\DNS PROCCESSING\Batchtest\*.txt').fullname
$myOutput = @() # Declare empty array
foreach ($FileName in $FileList) {
$myOutput += foreach ($DomainName in (Get-Content $FileName)) {
try {
$NSRecords = Resolve-DnsName $DomainName -Type NS -EA 1 | Where-Object { $_.QueryType -eq 'NS' }
[PSCustomObject]@{
Resolved = $true
Rmatch = $DomainName -match $Domainfinal