About Me

My photo
HANUMANGARH, RAJASTHAN, India

Thursday 17 December 2020

Enable winrm and psremoting in remote computer

 Winrm.ps1

winrm enumerate winrm/config/listener

Remove-Item -Path WSMan:\Localhost\listener\listener* -Recurse #removes all listeners in place (http and https)

Enable-PSRemoting -SkipNetworkProfileCheck -Force #creates the http listener and enables winrm for remote management

$Cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName $env:computername #creates the cert for https listener

New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $Cert.Thumbprint –Force

winrm enumerate winrm/config/listener

 

 

 

copy.ps1

#use recurse only if you want to copy entire content

# if you want to copy particular file Copy-Item "\\servername\c$\" -Destination "\\$server\c$\temp\"

$serverlist = Get-Content c:\PS\computers.txt

 

$count = 1

 

ForEach ($server in $Serverlist)

 

{

 

 

try

{

 

#Copy-Item -path "\\mspcsc12sccmw12\c$\Richika\31.28.8" -Destination "\\$server\c$\temp\" -Recurse

Copy-Item -path "\\IGLC00PF1LA6CW\c$\PS\winrm.ps1" -Destination "\\$server\c$\temp\"

 

write-host $count copied for $server " -ForegroundColor Green

}

 

catch

 

{

 

 

write-host $count failed for $server " -ForegroundColor Red

 

 

}

$count = $count + 1

}

 

 

 

Configure_winrm.ps1

$computers = Get-Content  c:\PS\computers.txt

 

foreach($computer in $computers)

{

write-host " working for $computer " -ForegroundColor Green

 

Invoke-Command -ComputerName $computer -ScriptBlock {

 

 

 

#Start-Process c:\temp\winrm.ps1

 

& "c:\temp\winrm.ps1"

#& "c:\temp\winrm_configure.ps1"

 

}

}

 

 

 

 

 

 

STEPS:

  1. Run copy script to push winrm.ps1 on servers.
  2. Then 

Export contact from Justdial

  Extract Data From JustDial using Selenium Let us see how to extract data from Justdial using Selenium and Python. Justdial is a company th...