In the following post we will use Robocopy to restore files from previous version including all file information like attributes, timestamps, NTFS ACLs etc
The most admins just move the files from previous versions and lose the original file information.
If files were encrypted our deleted you can use the following method to restore your files, including all information, if shadow copies was configured!
First we need to get the path of the previous version:
Than we could run the following command to restore our files:
robocopy "\\fileserver\c$\data001\@GMT-2019.11.28-11.06.38\testtree" "\\fileserver\c$\data001\testtree" /E /COPYALL /DCOPY:T
Explanation of the switches used in robocopy:
Copy directory recursively (/E)
Copy all file information (/COPYALL, equivalent to /COPY:DATSOU, D=Data, A=Attributes, T=Timestamps, S=Security=NTFS ACLs, O=Owner info, U=Auditing info)
Preserve original directories Timestamps (/DCOPY:T).
Tuesday, February 11, 2020
Friday, February 7, 2020
GET AZURE AD USER SYNCHRONIZATION TIME
First you have to connect to MSOnline using your credentials:
Than you can get the attribute called LastDirSyncTime using the following command:
$credential = Get-Credential
Import-Module MSOnline
Connect-MsolService -Credential $credential
Import-Module MSOnline
Connect-MsolService -Credential $credential
Than you can get the attribute called LastDirSyncTime using the following command:
Get-MSOlUser -UserPrincipalName "tim.buntrock@domain.com" | Select-Object LastDirSyncTime
Labels:
Active Directory,
Azure,
Office365
Tuesday, December 17, 2019
PowerShell Get Domain Controller OS and hardware infos
You can use the following Script to recieve the following information:
ComputerName
OperatingSystem
Memory in GB
CPU
$DCs = Get-ADDomainController -Filter *
foreach ($DC in $DCs) {
if (-not (Test-Connection -ComputerName $DC -Quiet -Count 1)) {
Write-Verbose -Message "The DC [$DC] is offline."
} else {
$os = Get-CimInstance -ComputerName $DC -ClassName Win32_OperatingSystem
$mem = [math]::Round((Get-WmiObject -Class Win32_ComputerSystem -computer $DC).TotalPhysicalMemory/1GB)
$cpu = Get-CimInstance -ComputerName $DC -ClassName Win32_Processor
[pscustomobject]@{
ComputerName = $DC
OperatingSystem = $os.Caption
Memory = $mem
CPU = $cpu.Name
}
}
}
ComputerName
OperatingSystem
Memory in GB
CPU
$DCs = Get-ADDomainController -Filter *
foreach ($DC in $DCs) {
if (-not (Test-Connection -ComputerName $DC -Quiet -Count 1)) {
Write-Verbose -Message "The DC [$DC] is offline."
} else {
$os = Get-CimInstance -ComputerName $DC -ClassName Win32_OperatingSystem
$mem = [math]::Round((Get-WmiObject -Class Win32_ComputerSystem -computer $DC).TotalPhysicalMemory/1GB)
$cpu = Get-CimInstance -ComputerName $DC -ClassName Win32_Processor
[pscustomobject]@{
ComputerName = $DC
OperatingSystem = $os.Caption
Memory = $mem
CPU = $cpu.Name
}
}
}
Labels:
Active Directory,
Powershell
Thursday, November 28, 2019
Adding the Attribute Editor tab for Active Directory objects
For some objects and maybe for some systems using a specific language, the attributes tab won’t appear, even when you have the “Advanced” view selected. This was maybe caused by a faulty forest update or misconfiguration. To fix this issue we must update the DisplaySpecifiers in our AD Configuration.
The following example will show you how to update it for AD User objects.
Open ADSIEdit
Click “Connect to” under the actions menu
Leave the defaults except select the well known naming context “Configuration”
Expand the Configuration Branch and select CN=DisplaySpecifiers container
Expand your language code CN=407 (for de-DE) other languages codes could be found at: https://support.microsoft.com/en-us/help/324097/list-of-language-packs-and-their-codes-for-windows-2000-domain-control
Click on CN=user-Display
Double click AdminPropertyPages and add the following value: 11,{c7436f12-a27f-4cab-aaca-2bd27ed1b773}
If you want to see the attribute flag on other objects you have to add 12,{c7436f12-a27f-4cab-aaca-2bd27ed1b773} to the AdminPropertyPages, like CN=organizationalUnit-Display or CN=computer-Display.
The following example will show you how to update it for AD User objects.
Open ADSIEdit
Click “Connect to” under the actions menu
Leave the defaults except select the well known naming context “Configuration”
Expand the Configuration Branch and select CN=DisplaySpecifiers container
Expand your language code CN=407 (for de-DE) other languages codes could be found at: https://support.microsoft.com/en-us/help/324097/list-of-language-packs-and-their-codes-for-windows-2000-domain-control
Click on CN=user-Display
Double click AdminPropertyPages and add the following value: 11,{c7436f12-a27f-4cab-aaca-2bd27ed1b773}
If you want to see the attribute flag on other objects you have to add 12,{c7436f12-a27f-4cab-aaca-2bd27ed1b773} to the AdminPropertyPages, like CN=organizationalUnit-Display or CN=computer-Display.
Labels:
Active Directory
Tuesday, November 12, 2019
Get all DFS Folder targets of a DFS path
Find attached the script to get the DFS folder targets. The targets will be saved to c:\temp\DFSFolderTargets.csv. Just change the variable $DFSPath = "\\Domainfqdn\Folder\*" to your DFS path.
$DFSPath = "\\Domainfqdn\Folder\*"
$DFSPath
$DFSNFolders = Get-DfsnFolder $DFSPath
foreach($DFSNFolder in $DFSNFolders )
{
$DFSTarget = Get-DfsnFolderTarget $DFSNFolder.Path | Select Path,TargetPath
$DFSTarget | Export-Csv "c:\temp\DFSFolderTargets.csv" -NoTypeInformation -Append
}
$DFSPath = "\\Domainfqdn\Folder\*"
$DFSPath
$DFSNFolders = Get-DfsnFolder $DFSPath
foreach($DFSNFolder in $DFSNFolders )
{
$DFSTarget = Get-DfsnFolderTarget $DFSNFolder.Path | Select Path,TargetPath
$DFSTarget | Export-Csv "c:\temp\DFSFolderTargets.csv" -NoTypeInformation -Append
}
Labels:
Active Directory,
DFS,
Powershell
Subscribe to:
Posts (Atom)

