Author Posts

August 22, 2017 at 8:07 am

Hello all, i'm on this forum for a while and i find it amazing resource pool for almost anything i can image for creating useful tools and scripts.
To cut the story short, i decided to share my humble script if anybody finds it helpful. I know i did...:)
Script is simple, it gets date and creates folder for that date and then copies from source to destination.
It gets list of computers from text file, then proceeds to list all filtered content(in this case, i needed folders with exact part of the name)
As i said, simple but thats what PS is all about, right? Make it simple, guys! Cheers

$today = Get-Date -Format "dd-MM-yyyy"
$computers = Get-Content "C:\computers.txt"
$folders = gci "\\$computers\D\*" -Directory -Filter *filter names of folders* 

Foreach ($computer in $computers){

        if(!(Test-Path -path "c:\test\$computer"))
            New-Item -ItemType directory -path "c:\test\$today\$computer" 

        Copy-Item $folders -Destination "c:\test\$today\$computer" -Recurse

August 24, 2017 at 7:00 pm

How you like this one?

Function Get-Arp
    arp -a | select -skip 3 | foreach {
        $ip,$mac,$type = -split $_
        New-Object -Type PSObject -Property @{
            InternetAddress = $ip
            PhysicalAddress = $mac
            Type = $type
            HostName = (resolve-dnsname -DnsOnly -ErrorAction SilentlyContinue $ip).NameHost