Loading...

Check for corrupted File with Powershell:

Get-ChildItem -Path D:\Shares -Recurse | foreach {
    get-Content $_.Fullname | out-null
    $error[0].CategoryInfo.TargetName | Out-File -FilePath C:\Logs\Corruptions.log -Append -Force
    $error.Clear()
    }
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

$dc = [System.DirectoryServices.ActiveDirectory.Domain]::getCurrentDomain().DomainControllers | Select -First 1
$LDAPs = [ADSI]"LDAP://$($dc.name):636"
try {
   $Connection = [adsi]($LDAPS)
} Catch {
}
If ($Connection.Path) {
   Write-Host "Active Directory server correctly configured for SSL, test connection to $($LDAPS.Path) completed."
} Else {
   Write-Host "Active Directory server not configured for SSL, test connection to LDAP://$($dc.name):636 did not work."
}
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Rescan all Disks on all Nodes of a Windows Cluster, this is very usefull on a Hyper-V Cluster with Cluster-Shared-Volumes (CSV) if you add a new LUN.

#region Function SCE_Storage_Diskscan

function SCE_Storage_DiskRescan {
<#  
.SYNOPSIS  
    Rescan all Disks on all Nodes of a Cluster
.DESCRIPTION  
    Rescan all Disks on all Nodes of a Cluster
.EXAMPLE  
    SCE_Storage_Diskscan Cluster1
#>

  param(
    [Parameter(Mandatory=$true)]
    [string] $clustername
  )

foreach ($Clustername1 in $Clustername){
    $hosts1 = Get-ClusterNode -Cluster $Clustername1 | select -ExpandProperty name
    write-host -ForegroundColor DarkYellow "Start with Cluster: $Clustername1"
foreach ($host1 in $hosts1){
    write-host $host1
    $host1|%{Invoke-Command  -computername $host1  -scriptblock { & echo "rescan" | diskpart | out-null }}
    }
}
}
#endregion
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Compare all Networks of 2 Hyper-V Nodes in a Hyper-V Cluster. Please check Network Adapter of your Cluster in the Script.

#region Function SCE_Network_Compare
function SCE_Network_Compare {
<#  
.SYNOPSIS  
    Compare LogicalNetworks on Hyper-V Cluster1
.DESCRIPTION  
    Compare Logical Networks between 2 Hosts of a Hyper-V Cluster
.EXAMPLE  
    SCE_Network_Compare -SOURCEHOST host1 -TARGETHOST host2 -NIC Frontend
    SCE_Network_Compare -SOURCEHOST dahyp5 -TARGETHOST host1 -NIC Mgnt
#>

  param(
    [Parameter(Mandatory=$true)]
    $SOURCEHOST,

    [Parameter(Mandatory=$true)]
    $TARGETHOST,
    $NIC = "FE"
  )
If ($SOURCEHOST -eq "0" -or $TARGETHOST -eq "0"){ 
    Write-Host "SharedCluster_CompareLogicalNetworkOn2Hosts -Source $SOURCEHOST -Target $TARGETHOST -NIC $NIC" } else {
    # Check the Network Adapter of your Environement
    If ($NIC -eq "Frontend"){$c = "Microsoft Network Adapter Multiplexor Driver #2"}
    If ($NIC -eq "Mgnt"){$c = "Microsoft Network Adapter Multiplexor Driver #3"}

    $a = Get-SCVMHostNetworkAdapter -Name $c -VMHost $SOURCEHOST |
        Select-Object -ExpandProperty LogicalNetworks | Select-Object -ExpandProperty name
    $b = Get-SCVMHostNetworkAdapter -Name $c -VMHost $TARGETHOST |
        Select-Object -ExpandProperty LogicalNetworks | Select-Object -ExpandProperty name

    Compare-Object $a $b
    }
}
#endregion
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

foreach ($line in (Get-Content C:\temp\shares.txt)){

Get-childitem $line -recurse -depth 4 -directory |
Get-Acl | % {
    $path = $_.Path
    $a+=$_.Access | % {
        New-Object PSObject -Property @{
            Folder = $path.Replace("Microsoft.PowerShell.Core\FileSystem::","")
            Access = $_.FileSystemRights
            #Control = $_.AccessControlType
            User = $_.IdentityReference
            #Inheritance = $_.IsInherited
            }
        }
    } | select -Property Folder, User, Access
  }

$a|export-csv C:\temp\ACL-Report.csv -Encoding UTF8
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Import-Module "C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1"

#--------variablen
$servername = "servername"
$sourcepath = "C:\ClusterStorage\Volume17\mig\$servername\" #<----- temp Folder for vmdk
$destpath = "C:\ClusterStorage\Volume17\$servername\" #<---- hyper-v vm

#---------execution
$List = Get-ChildItem $sourcepath | where {$_.extension -eq ".vmdk" -and $_.Name -notlike '*flat*' }
foreach ($vmdk in $List) 
    {
    Write-Host  $sourcepath$vmdk
    ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath $sourcepath$vmdk -DestinationLiteralPath $destpath -VhdType FixedHardDisk -VhdFormat vhdx
    }
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

<#  
.SYNOPSIS  
    Copy VMware VM to Hyper-V
.DESCRIPTION
    Copy VMDK from VMware Datastore to temp Location and migrate VMDK to VHDX 
.NOTES
    Version: 1.0
    File Name  : vmware2hyperv.ps1
    Author     : tk@ironbit.at
    Requires   : PowerCLI, MvmcCmdlet
    Todo: 
    Version: 30.10.2015
.LINK
    
.EXAMPLE
   
#>

#Import Modlues and Snapins
Import-Module "C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1"
Add-PSSnapin VMware.VimAutomation.Core
#Import-Module -Name "virtualmachinemanager"

# Connect to vCenter
connect-viserver vcenter1.mgnt.local
#get-datastore
#get-datacenter
#Get-HardDisk -VM $servername 

#region VARIABLES
 #--VMWARE
    $datastores = "tahds14:vmfs-cloud-tahds1","tahds14:vmfs-cloud-tahds2"
    $datacenter = "DCenter01" #DataCenter VMware (get-datacenter)
 #--SERVER
    $servername = "myServer1" #VM Name
 #--PATH
    $temp = "C:\ClusterStorage\Volume25\mig\$servername\" #temp folder vmdk copy
    $destpath = "C:\ClusterStorage\Volume21\$servername\" #hyper-v vm volume
    $date = Get-date
#endregion

#region EXECUTION
    if(!(Test-Path -Path $temp )){ New-Item -ItemType directory -Path $temp } #Check if temp folder exist

 foreach ($datastore in $datastores)
 {
 #--Copyjob
    $i = $datastore.Split("-")
    $ii=$i[3]
    $newtestpath = $temp + $ii +"\"
    if(!(Test-Path -Path $newtestpath )){ New-Item -ItemType directory -Path $newtestpath } #Check if newtemp folder exist
 
    Write-Host -foregroundcolor "green" "-------------------- START CopyJob "(get-date)"--------------------"
    Copy-DatastoreItem vmstore:\$datacenter\$datastore\$servername\* $newtestpath
    Write-Host -foregroundcolor "magenta" "-------------------- STOP CopyJob "(get-date)"--------------------"
 }
 
 #--move disks und rename
    Write-Host -foregroundcolor "green" "-------------------- START Moving Disks "(get-date)"--------------------"
    #Move-Item "C:\ClusterStorage\Volume25\mig\$servername\server.vmdk" "C:\ClusterStorage\Volume25\mig\$servername\"
    ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath "C:\ClusterStorage\Volume25\mig\server\001\server.vmdk" -DestinationLiteralPath "C:\ClusterStorage\Volume21\$servername\server.vhdx" -VhdType FixedHardDisk -VhdFormat vhdx
    Write-Host -foregroundcolor "magenta" "-------------------- STOP Moving Disks "(get-date)"--------------------"
#endregion
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

This Powershell Function lists the Job History of a CommVault Client.

The Scripts works with a token File. See my Post how to create a Token File for CommVault.

#region ------------ Get-CVjobhistory
#region Variables
$xmlstore = "C:\Scripts\Modules\Commvault\XML"
$CVTokenFile = "C:\Scripts\Modules\Commvault\CV_token_user.txt"
$global:CVCommandPath = (gci env: | ?{$_.name -like "CV_*" }).value
$CVGroupName = "My_CV_Group"
#endregion

function Get-CVJobHistory {
[cmletbinding(SupportsShouldProcess=$true)]
Param(
<#
.Synopsis
   Get CommVault Client Job History
.DESCRIPTION
   Get CommVault Client Job History
.EXAMPLE
   Get-CVjobhistory -ClientName servername
.EXAMPLE
   Get-CVjobhistory -ClientName servername -DataAgentType Q_WINDOWS_FS -SubClientName default
#>
    [Parameter(Mandatory=$true)][string]$ClientName,
    [Parameter(Mandatory=$false)][string]$SubClientName="default",
    [Parameter(Mandatory=$false)][string]$DataAgentType="Q_FILESYSTEM"
)
     (& $CVCommandPath\QList.exe jobhistory -c $ClientName -a $DataAgentType -b defaultBackupSet -s $SubClientName -dispJobTime -tf $CVTokenFile)
}
#endregion
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

PowerShell Function to get the Schedule of a CommVault Client.

Syntax: Get-CVSchedule -Clientname servername

#region ------------ Get-CVSchedule
<#
.Synopsis
   Get CommVault Client Schedule Info
.DESCRIPTION
   Get CommVault Client Schedule Info
.EXAMPLE
   Get-CVSchedule -ClientName servername
#>
#region Variables
$xmlstore = "C:\Scripts\Modules\Commvault\XML"
$CVTokenFile  = "C:\Scripts\Modules\Commvault\CV_token_user.txt"
$CVCommandPath   = (gci env: | ?{$_.name -like "CV_*" }).value
#endregion
function Get-CVSchedule {
[cmdletbinding(SupportsShouldProcess=$true)]
Param(
    [Parameter(Mandatory=$true,ParameterSetName="Single")][string]$ClientName,
    [Parameter(Mandatory=$true,ParameterSetName="All")][Switch]$All
)
 
    if ($PSCmdlet.ParameterSetName -eq "Single") {
        [XML] $b = (& $CVCommandPath\QOperation.exe execute -af $xmlstore\CV_sched_client.xml -ClientName $ClientName -tf $CVTokenFile )
        $Schedule = $b.TMMsg_GetTaskListResp.taskDetail.task.taskname
        return $Schedule
    } elseif ($PSCmdlet.ParameterSetName -eq "All") {
        # Read Policies
        $CommandDuration=measure-command {
            $SchedulePolicies = (& $CVCommandPath\qlist Schedulepolicy -tf $CVTokenFile )
        }|select -ExpandProperty TotalSeconds
        write-verbose "Read Duration $CommandDuration sec"

        # Erstellung des Policyarrays
        $PolicyArray=new-object system.collections.arraylist
        write-verbose "$($SchedulePolicies|select -skip 7|measure|select -ExpandProperty count) Policies has been delivered"
        $SchedulePolicies|select -skip 7|foreach {
            $Schedulepolicy=$_
            $entry= $Schedulepolicy -split '\s{2,100}'
            if ($entry[0] -match "(WIN|HYPERV)") {
                [void] $PolicyArray.add($entry[0])
                write-host -NoNewline "."
            }
        }
        $PolicyArray|Out-File $xmlstore\Schedules.txt
        Return $PolicyArray
    }
}
#endregion

Content of XML File:

<TMMsg_GetTaskListReq>
<filter schedules="1" isCalendar="0" policy="1">
<entity>
<clientName/>
</entity>
</filter>
</TMMsg_GetTaskListReq>
Read Full Article
Visit website
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

With a Token File you don`t have to login each time you want to use a CommVault Command. Also every other User can use the (PowerShell) Commands.

The User should have Master Role in CommVault at the CommVault Client Group.

.\QLogin.exe -cs CommVault_Server -f C:\Scripts\Commvault\CV_token_user.txt

After this Command you get the Prompt for the User and his Password.

Read Full Article
Visit website

Read for later

Articles marked as Favorite are saved for later viewing.
close
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Separate tags by commas
To access this feature, please upgrade your account.
Start your free month
Free Preview