þÿ# Get-ADDate.ps1 # # Esta función regresa el valor de una fecha, compatible con la propiedad accountExpires de AD. # # Copyright (C) Victor Lozano 2011 # victor.lozano@mildecabeza.com # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # function Get-ADTicks{ param([DateTime]$date) #Total de años desde del año 1 al 1601 $0to1601 = 1600 #Número de años bisiestos. $leapYears = $0to1601 / 4 #Total de días. $days1601 = ($0to1601 * 365) + $leapYears -12 #Total de horas. $hrs1601 = $days1601 * 24 #Total de minutos. $min1601 = $hrs1601 * 60 #Total de segundos. $sec1601 = $min1601 * 60 #Nanosegundos. [long]$100NanoSec1601 = $sec1601 * 10000000 #se regresa el valor de la fecha menos 1600 años. return $date.ticks - $100NanoSec1601 } #Ejemplo de uso. #Se obtiene una fecha actual. $NewDate = Get-Date #Se convierte la fecha. #Get-ADTicks $NewDate