Command



1. Change data time in windows using PowerShell

C:> Set-ItemProperty .\filename.txt -Name CreationTime -Value "11/13/2018 06:30:00 PM"


2. Write the folder name to the text file

C:\FolderName> dir > C:\filename.txt


3.Remote login to server using Power Shell Script

echo "Connecting to 192.168.xx.xx"
$Server="192.168.xx.xx"
$User="userName"
$Password="Passowrd"
cmdkey /generic:TERMSRV/$Server /user:$User /pass:$Password
mstsc /v:$Server


4.Copy file to remote server

$Source = "C:\copy\1.txt"
$Dest   = "\\192.168.xx.xx\C$\Past"
$Username = "administrator"
$Password = ConvertTo-SecureString "Password" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential($Username, $Password)

New-PSDrive -Name J -PSProvider FileSystem -Root $Dest -Credential $mycreds -Persist
Copy-Item -Path $Source -Destination "$Dest"

5. Release Port (Kill process)

netstat -ano | findstr :<yourPortNumber>
taskkill /PID <typeyourPIDhere> /F

No comments:

Post a Comment