0 votes

Hi - random PowerShell question (I do seem to ask more PowerShell questions than Adaxes questions...!).

We have a little bit of code to return the current value of an AD attribute as below, and it should update a different timestamp attribute in AD after reading it.

I have it almost working but am 'very' bad at working out how to properly convert variables in PowerShell, and need to create "$newNums" which is derived from a Date\Time stamp, into a Windows NT time numeric value, then into an Adaxes.ADSI.LongInteger (I think!).

        # Set new timestampin 24 hours
        $newTime = (Get-Date).AddDays(1)

        $newNums= << Can’t work out how to convert the GetDate format timestamp to a “Windows Time” Adaxes format Long Integer>>

        $pc.Put("<<attribute>>", $newNums)
        $pc.SetInfo()  

Anyone who can work this out is my hero..!

Rgds

by (1.6k points)

1 Answer

0 votes
by (216k points)
selected by
Best answer

Hello,

This one will work:

# Set new timestampin 24 hours
$newTime = (Get-Date).AddDays(1)

$newNums= [Softerra.Adaxes.Adsi.ADsLargeInteger]$newTime.ToFileTime()

$pc.Put("<<attribute>>", $newNums)
$pc.SetInfo()
0

Thanks - it's always so easy when you see it on paper!

Related questions

0 votes
1 answer

Hi All, I am currently using the 30 day free trial of Adaxes and seeing if we can use it to achieve our method of user provisioning. I am looking into server-side ... variable value within an SQL query Can this be achieved? Any help is much appreciated, Thanks

asked Feb 1 by Lewis (40 points)
0 votes
1 answer

Hi, Is there any native way to auto-increment a custom interger attribute? I know I can use a PS script, but just wondering whether there is a quick way to use an Adaxes action i.e. "CustomAttributeInt1 = CustomAttributeInt1+1" Thanks

asked May 29, 2013 by firegoblin (1.6k points)
0 votes
0 answers

We currently convert user mailboxes to shared mailboxes during deprovisioning process but if the user mailbox was already a shared mailbox then the script throws an error ... user mailbox. Here is the actions of the current deprovision command: Thanks!

asked Oct 1 by Carlos (40 points)
0 votes
1 answer

As we use the dateformat dd.mm.yyyy I set it as required in this format in the regesp. Is it possible to convert the CustomAttributeText5 from "dd.mm.yyyy" in "yyyy ... [datetime]::ParseExact($entryDatePropertyName, "dd.MM.yyyy", $null).ToString("yyyy-MM-dd")

asked Jun 11 by fabian.p (380 points)
0 votes
1 answer

Hi, I would like to add a CSV file during my group creation form and add users from CSV to new created group. However the CSV file is converted into Binary file and I am ... help is really appreciated. Thanks! PS: What I tried so far and error message I got

asked Jul 3, 2023 by wintec01 (1.5k points)
3,538 questions
3,229 answers
8,224 comments
547,749 users