Hello Powershell friends,
I am trying to set a bunch of varaibles, and I want these variables to be set at a specific time (as they set up log file paths which contain time and date stamps).
So here is my function:
Function Set-Variables { #---------------------------------------------------------- #STATIC VARIABLES #---------------------------------------------------------- $log = "c:\scripts\log\ADImportLog$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $failed = "c:\scripts\log\FailedImportAccountsList$(get-date -f dd-MM-yyyy-HH-mm-ss).log" # This will be used to create a list of failed accounts, useful for making re-attempts $movelog = "c:\scripts\log\movelog$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $date = Get-Date $addn = (Get-ADDomain).DistinguishedName $dnsroot = (Get-ADDomain).DNSRoot $i = 2 $tempOU = "OU=TempImport,OU=Users,DC=corp,DC=,DC=co,DC=uk" #Accounts are initially created here, change as necessary. Once validated, they are moved to correct OU $UPNSuffix = "" $MEU = "c:\scripts\log\MEU$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $MEUfail = "c:\scripts\log\MEUfailed$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $MEUfail1 = "c:\scripts\log\MEUNotFound$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $movefail = "c:\scripts\log\MoveFail$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $MailFRD = "c:\scripts\log\EnforceLog_FRD_Details$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $365lic = "c:\scripts\log\365License$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $365Enable = "c:\scripts\log\365Enable$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $365EnableF = "c:\scripts\log\365EnableFailed$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $AzureCSV = "c:\scripts\log\AzureImport$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $AzureURI = "" #Add in URI path to BLOB here $AzureToken = "" #Add in SAS token here $AzureRootFolder = "/" $AzureImport = "c:\scripts\log\AzureImport$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $Rename = "c:\scripts\log\Rename$(get-date -f dd-MM-yyyy-HH-mm-ss).log" $ConvertShared = "c:\scripts\log\ConvertShared$(get-date -f dd-MM-yyyy-HH-mm-ss).log" }
I simply call this within other functions like so:
Set-Variables
However for some reason nothing happens, and no variables are set.
Something simple I expect if someone could kindly enlighten me
Many Thanks