<#
.Synopsis
Adds a user or group to local administrator group
.Description
This scripts adds the given user or group to local administrators group on given list of servers.
.Parameter ComputerName
Computer Name(s) on which you want to add user/group to local administrators
.Parameter ObjectType
This parameter takes either of two values, User or Group. This parameter indicates the type of object
you want to add to local administrators
donderdag 6 november 2014
Powershell - Split large files
#############################################
# Split a log/text file into smaller chunks #
#############################################
#
# WARNING: This will take a long while with extremely large files and uses lots of memory to stage the file
#
# Set the baseline counters
#
# Set the line counter to 0
$linecount = 0
# Set the file counter to 1. This is used for the naming of the log files
$filenumber = 1
# Prompt user for the path
$sourcefilename = Read-Host "What is the full path and name of the log file to split? (e.g. D:\mylogfiles\mylog.txt)"
# Prompt user for the destination folder to create the chunk files
$destinationfolderpath = Read-Host "What is the path where you want to extract the content? (e.g. d:\yourpath\)"
# Split a log/text file into smaller chunks #
#############################################
#
# WARNING: This will take a long while with extremely large files and uses lots of memory to stage the file
#
# Set the baseline counters
#
# Set the line counter to 0
$linecount = 0
# Set the file counter to 1. This is used for the naming of the log files
$filenumber = 1
# Prompt user for the path
$sourcefilename = Read-Host "What is the full path and name of the log file to split? (e.g. D:\mylogfiles\mylog.txt)"
# Prompt user for the destination folder to create the chunk files
$destinationfolderpath = Read-Host "What is the path where you want to extract the content? (e.g. d:\yourpath\)"
Powershell v3 cmdlets
#enable psremote through psexec
psexec \\[computer name] -u [admin account name] -p [admin account password] -h -d powershell.exe "enable-psremoting -force"
#enable ping through firewall
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow
#enable script running policy
Set-ExecutionPolicy RemoteSigned
#search an user in your domain
Get-ADUser -Filter {name -like 'name*'}
#search every locked account in domain
Search-ADAccount -lockedout -UsersOnly| format-table userprincipalname, name, passwordexpired, lastlogondate
#unlock account
Unlock-ADAccount username -Confirm
#to get all groups that a user is member of
Get-ADprincipalgroupmembership username| select name
#change computer hostname in domain
psexec \\[computer name] -u [admin account name] -p [admin account password] -h -d powershell.exe "enable-psremoting -force"
#enable ping through firewall
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow
#enable script running policy
Set-ExecutionPolicy RemoteSigned
#search an user in your domain
Get-ADUser -Filter {name -like 'name*'}
#search every locked account in domain
Search-ADAccount -lockedout -UsersOnly| format-table userprincipalname, name, passwordexpired, lastlogondate
#unlock account
Unlock-ADAccount username -Confirm
#to get all groups that a user is member of
Get-ADprincipalgroupmembership username| select name
#change computer hostname in domain
Rename-Computer -ComputerName Srv01 -NewName Server001 -DomainCredential domain\username Force -PassThru -Restart
Abonneren op:
Posts (Atom)