x

Serwis finansowy

czwartek, 22 stycznia 2015

Sprawdzamy czy wszystkie serwery w sieci są dostępne

cls

Write-Host

Write-Host "Checking if PowerShell module for Active Directory is available on this machine..."

$ADModuleAvailable = $null

$ADModuleAvailable = Get-Module -ListAvailable | where {$_.Name -eq "ActiveDirectory"}

if ($ADModuleAvailable -eq $null){

Write-Host -ForegroundColor Red "PowerShell module for Active Directory is not available on this machine."

Write-Host -ForegroundColor Red "Please run this script on a domain controller or on a machine that has Active Directory management tools installed."

Write-Host

Exit}

else{

Write-Host -ForegroundColor Green "PowerShell module for Active Directory is availble."}

Write-Host





Write-Host "Checking if PowerShell module for Active Directory is already loaded..."

$ADModuleLoaded = $null

$ADModuleLoaded = Get-Module | where {$_.Name -eq "ActiveDirectory"}

if ($ADModuleLoaded -eq $null){

Write-Host "Loading PowerShell module for Active Directory ..."

Import-Module -Name "ActiveDirectory"}

Write-Host -ForegroundColor Green "Powershell module for Active Directory is loaded."

Write-Host








$ServerList = $null

$ServerList = Get-ADComputer -Filter '(OperatingSystem -like "*Server*") -AND (Enabled -ne "False")' -Properties DNSHostName | Select-Object DNSHostName | Sort-Object DNSHostName





$IsOnline = $null

ForEach ($Server in $ServerList) {

$IsOnline = Test-Connection -ComputerName $Server.DNSHostName -BufferSize 10 -Count 1 -Quiet

if ($IsOnline -eq $true){

Write-Host -ForegroundColor Green $Server.DNSHostName "is ONLINE"



}

else {

Write-Host -ForegroundColor Red $Server.DNSHostName "is OFFLINE"



}

}

żródło       


Error 0x800700DE

Microsoft podaję że przyczyną jest zbyt długa nazwa pliku ( http://support.microsoft.com/kb/894630) u mnie jednak wystarczyło usunięcie kropki na końcu nazwy pliku użytkownika.

Jak sprawdzić wersję Powershell'a na której pracuję?

$PSVersionTable

środa, 21 stycznia 2015

Zmiana pliku hosts na kilku komputerach - powershell

Set-ExecutionPolicy Unrestricted
CLS
Import-CSV "d:\Servers.csv" | % {
    $Server = $_.ServerName
 $adminpath = Test-Path "\\$Server\admin$"
 If ($adminpath -eq "True")
  {
         $hostfile = "\\$Server\c$\Windows\System32\drivers\etc\hosts"
         Write-Host –NoNewLine "Updating $Server..."
         "    192.168.1.1   mojwpis1" | Out-File $hostfile -encoding ASCII -append
         "    192.168.1.1    mojwpis2" | Out-File $hostfile -encoding ASCII -append
         Write-Host "Done!" 
  
  }
 Else
  {
            Write-Host -Fore Red "Can't Access $Server"
  }
 }

Plik ServersName:
ServerName
Server1
Server2

IPhone nie uruchamia się - czarny ekran!

W IPhone 4S pomogło jednoczesne wciśnięcie przycisku Usypianie/Budzenie oraz przycisku Początek i przytrzymanie ich przez 10 sekund, aż zostało wyświetlone logo firmy Apple.
 
 

wtorek, 20 stycznia 2015

Zmiana wielkich liter na małe w Powershell

Wpisujemy:
$string = "ABCD"
$string.toLower()
abcd
 
Aby zamienić ciąg małych liter na wielkie wpisujemy
$string.toUpper()

poniedziałek, 19 stycznia 2015

Jak sprawdzić jakie kontrolery domeny (AD DC) są w danym drzewie?

W okienku Powershell'a wpisujemy:

$DC_domain =
[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$DC_domain.FindAllDomainControllers() | select Name, SiteName, IPAddress | Format-Table

Gdzie za darmo znajdę materiały szkoleniowe Microsoft?

Na stronie https://www.microsoft.com/learning/en-us/companion-moc.aspx znajdziemy dużo pomocnych w nauce systemów firmy Microsoft. Materiały przeznaczone są głównie do pracy z książkami Microsoft, ale bez nich też stanowią ciekawe źródło wiedzy.