Hi
I am sick of my colleague stealing the codes from my script and claim that as his own work. Is there a way of encrypting the script so he cant view the content of the script but at the same time he can run the script.
Hi
I am sick of my colleague stealing the codes from my script and claim that as his own work. Is there a way of encrypting the script so he cant view the content of the script but at the same time he can run the script.
Hello all,
before digging into the script, maybe someone sees something I missed...
$range = 1..100 ForEach ($_ in $range){ if ($_ % 7 -ne 0 ) { continue; } $timer = New-Object System.Timers.Timer Register-ObjectEvent -InputObject $timer -EventName Elapsed -Action { continue; } $timer.Interval = 1000 $timer.Autoreset = $false $timer.Enabled = $true Start-Sleep -s 10 Write-Host "$($_) is a multiple of 7" }
What I am trying to do is skip one step in a foreach loop (basically when a WMI Query does not finish, though that's not in the example code). So in general, using continue works fine (if mod 7 != 0 will skip the step of the foreach loop), using continue with the timer wont work. if I replace the continue; in the action with eg Write-Host 'Event Fired';, I can see that the Timer as such does work and does fire the event.
Curious, should it work or have I missed the obvious?
Thanks
Florian
This seems like a common occurance at any company but there really doesn't seem to be a solution for it. In Exchange people can reserve a conference room by inviting it to a meeting and with the proper setup the room mailbox will accept the meeting if the time slot is free. The problem comes in when the organizer of the meeting leaves the company. I'm working on a project using Exchange Web Services to clean out our room mailboxes of meetings which were scheduled by people who are no longer at the company. The only way I know how is through web services and through an account that has been given the impersonation right (which I am using).
The problem I'm having is that through web services there is a method on an appointment item called CancelMeeting which would do just this except I'm getting the below error:
Exception calling "CancelMeeting" with "0" argument(s): "User must be an organizer for CancelCalendarItem action."
I'm looking for any suggestions as I've been looking out over the Internet for quite a bit now and not really coming up with anything of use. Below is the code I'm using (cleaned up to remove company information). Any thoughts or input that could be helpful would be much appreciated.
#Address of object to connect to $roomAddress = 'room@contoso.com' #Path to the EWS DLL $dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll" #Load the EWS DLL [void][Reflection.Assembly]::LoadFile($dllpath) #Create a service object that supports Exchange 2010 SP1 $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP1) #Store the passed in credential #$service.Credentials = $credential #Web services url $uri=[system.URI] "https://ExhcangeServer.Contoso.com/EWS/Exchange.asmx" $service.Url = $uri #The impersonation details. $ImpersonatedUserId = New-Object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId $ImpersonatedUserId.IdType = 'smtpaddress' $ImpersonatedUserId.Id = $roomAddress $service.ImpersonatedUserId = $ImpersonatedUserId #Build a folder ID object $folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar,$roomAddress) #Bind to the mailbox and folder. $CalendarFolder = [Microsoft.Exchange.WebServices.Data.CalendarFolder]::Bind($service,$folderid) #Get up to 2000 entries from the folder and find any that are appointments from today and the next 5 days. $startDAte = get-date $endDate = (get-date).AddDays(+5) $cvCalendarview = new-object Microsoft.Exchange.WebServices.Data.CalendarView($StartDate,$EndDate,2000) $frCalendarResult = $CalendarFolder.FindAppointments($cvCalendarview) #Build a view $psPropset = new-object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties) $psPropset.RequestedBodyType = [Microsoft.Exchange.WebServices.Data.BodyType]::Text #Cancel the first meeting found (there is one here) $frCalendarResult.Items[0].CancelMeeting()
Scenario,
We have around 50 Groups each group is nested into differen group or is member of different group.
We are building different forest and need that information
Need powershell script that will get (information about group membership and export int o excel)
1) Group members information
2) Group memberof information
Hi
I got below one script to export share folder permission. But I am not getting where can i define the share folder path in the below script.
===============Script=============
Function Get-NtfsRights($name,$path,$comp) {$path=[regex]::Escape($path)$share="\\$comp\$name"$wmi= gwmi Win32_LogicalFileSecuritySetting -filter"path='$path'"-ComputerName $comp$wmi.GetSecurityDescriptor().Descriptor.DACL | where {$_.AccessMask -as[Security.AccessControl.FileSystemRights]} |select ` @{name="Principal";Expression={"{0}\{1}"-f $_.Trustee.Domain,$_.Trustee.name}}, @{name="Rights";Expression={[Security.AccessControl.FileSystemRights]$_.AccessMask }}, @{name="AceFlags";Expression={[Security.AccessControl.AceFlags]$_.AceFlags }}, @{name="AceType";Expression={[Security.AccessControl.AceType]$_.AceType }}, @{name="ShareName";Expression={$share}} } gc serverlist.txt | foreach { if ($shares = Get-WmiObject Win32_Share -ComputerName $_ | Where {$_.Path}) { $shares | Foreach { Write-Progress -Status "Get share information on $($_.__Server)" $_.Name Get-NtfsRights $_.Name $_.Path $_.__Server} } else {"Failed to get share information from {0}." -f $($_.ToUpper())} } | ft Principal,Rights,AceFlags,AceType -GroupBy ShareName -Wrap | Out-File result.txt
===============================================================
I need to see how many files over 3 years have been modifed on a large file share and export it to a .csv file
Good Afternoon everyone,
I am currently trying to promote my 2012 Server to a Domain Controller but when I am at the first step in the setup I get the Error Message
(German, Original Message):
[Bereitstellungskonfiguration] Fehler bei der Bestimmung, ob der Zielserver bereits ein Domänencontroller ist: Der Typ [Microsoft.Directory.Services.Deployment.DeepTasks.DeepTasks] wurde nicht gefunden: Vergewissern Sie sich, dass die Assembly, die diesen Typ enthält, geladen ist.
(Translated to English):
Error while determining, if the Targetserver already is a Domain Controller: The Type [Microsoft.Directory.Services.Deployment.DeepTasks.DeepTasks] was not found: Make sure, that the assembly, that contains this type, is loaded.
Thus I can neither Configure the AD-DS nor deinstall them via Server Manager. Any Help how to fix that problem would be greatly appricieated.
Hi
I am trying to pass a parameter to a remote script with an invoke-command.
If i run the invoke command with the script in the local computer it´s works, but when i call the invoke-command with the second script in other server it´s fails with a conversion error for the type [System.Collections.Specialized.NameValueCollection]
I think this can be because some serialization to transfer the data between the two servers. Any help??
The command:
Invoke-Command -computername $RemoteServerName -Credential $credential -Authentication Credssp -scriptblock {
param(
[String]$scriptDeploy,
[String]$BackupPath,
[String]$DeployPath,
[System.Collections.Specialized.NameValueCollection]$dtsConfigReplacements,
[System.Collections.Specialized.NameValueCollection]$dtsxReplacements
) &"$scriptDeploy" -BackupPath $BackupPath -DeployPath $DeployPath -dtsConfigReplacements $dtsConfigReplacements -dtsxReplacements $dtsxReplacements
} -ArgumentList $Script_To_Run, $script:BackupPath, $script:DeployPath, $script:dtsConfigReplacements, $script:dtsxReplacements
The command fails with this error:
Cannot process argument transformation on parameter 'dtsConfigReplacements'. Ca
nnot convert the "System.Collections.ArrayList" value of type "System.Collectio
ns.ArrayList" to type "System.Collections.Specialized.NameValueCollection".
+ CategoryInfo : InvalidData: (:) [BDesarrollo.
ps1], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Deploy.Aprovisionamiento.Desarrollo.ps1
I need to invoke a command line tool (imagine cmd or netsh) which can complete and return or remain interactive.
If I try Invoke-Command with cmd it returns without and error but doesn't remain interactive.
However, if I do it with my tool, I get this error:
Last compiled Sep 27 2012 07:53:09 Port Number: 7188+ CategoryInfo : NotSpecified: (:String) [], RemoteException+ FullyQualifiedErrorId : NativeCommandError+ PSComputerName : MyServer dlmcv - Copyright (C) 2011-2012, MyCorporation. All rights reserved
Is there a way to invoke and stay interactive?
How can I find out what this NativeCommandError was?
I found a wonderful script that allows me to bulk reset users passwords using the set-adaccountpassword cmdlet. The passwords change just fine but then when I set the user accounts to force a password change even if they are following the complexity requirements of our password policy they still cannot change their password.
I have even tested this out on a user account that wasn't changed by the cmdlet and it works fine, so it's following the password policy like it should. I am assuming that the cmdlet changes some ad attributes on the user account but for the life of me can't fine which ones it changes.
I even went as far as to change our password policy so that it was more relaxed, turn off password memory and changed the number of required characters, and I amd still having the same issue.
The password that I used is an 8 character complex password and works for any other users that were not changed by the cmdlet.
Here is the script that I used, it's modified script that I found online possibly even in this forum:
# import the AD module if (-not (Get-Module ActiveDirectory)){ Import-Module ActiveDirectory -ErrorAction Stop } # set new default password $password = ConvertTo-SecureString -AsPlainText "aaa4123!" -Force # get list of account names (1 per line) $list = Get-Content -Path c:\users\users.txt # loop through the list ForEach ($u in $list) { if ( -not (Get-ADUser -LDAPFilter "(sAMAccountName=$u)")) { Write-Host "Can't find $u" } else { $user = Get-ADUser -Identity $u $user | Set-ADAccountPassword -NewPassword $password -Reset $user | Set-AdUser -ChangePasswordAtLogon $false Write-Host "changed password for $u" }
Here is the password policy that I am using:
Policy | Setting |
---|---|
Minimum password length | 8 characters |
Password must meet complexity requirements | Enabled |
Store passwords using reversible encryption | Disabled |
Policy | Setting |
---|---|
Account lockout threshold | 5 invalid logon attempts |
Policy | Setting |
---|---|
Enforce user logon restrictions | Enabled |
Maximum lifetime for service ticket | 600 minutes |
Maximum lifetime for user ticket | 10 hours |
Maximum lifetime for user ticket renewal | 7 days |
Maximum tolerance for computer clock synchronization | 5 minutes |
Any help on the would be great.
I understand that PS save the history per PS-session up to 32767 cmdlets. I know that i can export the history to a .xml file, but...
Where is the ADAC history saved?
I can see that the history is still there after a restart of a DC, so I presume that is imported from a .xml file.
I'm right or?
Hi,
I wanted to make a script to automate cleaning of the wsus. All my rules work quite good, just on (last) rule gives me a time-out. (i'm fairly new to scripting). I've been looking to solve it but can't seem to find what the problem is.
The last line that gives the error is : $CleanupManager.PerformCleanup($CleanupScope)
When i execute this line i get the following message :
Exception calling “PerformCleanup” with “1″ argument(s): “Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
The statement has been terminated.”
At line:1 char:31
+ $CleanupManager.PerformCleanup <<<< ($CleanupScope)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
I suggest that the cleanup is not executed then ? How can i avoid the timeout ?
Any help would be appriciated.
Regards,
Jo
I have a powershell script that uses the Quest One ActiveRoles Management Shell for Active Directory snap-in.
Scenario 1
When I'm in the office, the script runs very quickly (1 min). No errors.
Scenario 2
When I take my laptop home, and log into the laptop using the same account (although I'm not connected to the domain), the script takes 20 minutes to complete. No errors.
I have Internet access both at work and at home.
Script Code:
Function TestImport($a) { Get-Date Write-Host "Importing CRL" $Q_CRL = Import-QADCertificateRevocationList -FileName $a Write-Host "Import Complete" $CRL_ThisUpdate = $Q_CRL.EffectiveDate $CRL_NextPublish = $Q_CRL.NextPublish $CRL_NextUpdate = $Q_CRL.NextUpdate Write-Host "CRL Effective Date/Time: $CRL_ThisUpdate" Write-Host "CRL Next Publish Date/Time: $CRL_NextPublish" Write-Host "CRL Next UPdate Date/Time: $CRL_NextUpdate" Get-Date } TestImport "C:\TEMP\My.CRL"
The slowness occurs when the script starts the import using the snap-in.
Get-PSSnapin returns the following:
Name : Microsoft.PowerShell.CoreGet-ExecutionPolicy shows: RemoteSigned
Does anyone have any ideas as to why the snap-in would be running so slowly? All the other parts of the script seem to run just fine; no slowness. Any help would be greatly appreciated.
-m
Has anyone ever saw this before and/or do they know whats causing it? When i try to run the query with the filter of 10.1.% it doesn't return anything. But when I negate the filter twice, I am actually getting the data I was looking for?!?!
PS C:\> gwmi -Namespace root\microsoftdns microsoftdns_atype -Filter "IPaddress LIKE '10.1.%'" | Select IPAddress -First 10
PS C:\> gwmi -Namespace root\microsoftdns microsoftdns_atype -Filter "NOT NOT IPaddress LIKE '10.1.%'" | Select IPAddress -first 10
IPAddress
---------
10.1.91.3
10.1.91.4
10.1.91.1
10.1.91.5
10.1.91.6
10.1.91.2
10.1.27.45
10.1.27.41
10.1.72.9
10.1.27.61
PS C:\>
I am trying to start 50 sessions on a server, but once I pass 25 new sessions, I get this error:
New-PSSession : [MyServer] Connecting to remote server systemarchi failed with the following error message : The WS-WinRM settings:
ConfigI have other servers, where i'm not limited to 25 sessions. Does anyone have a clue where to fix this?
I've been looking for a way to exclude Windows 7 machines from a GPO logon script that substitutes a local drive letter on our PCs. The Group Policy Management Editor has a tab for PowerShell scripts and I'm thinking I might be able to choose from'For this GPO, run scripts in the following order - Run Windows Powershell Scripts Last'to undo the original script's commands specifically for Win 7 PCs.
I've never written a PS script before so I'm researching how to do this, but if anyone has any suggestion for what I imagine would be a pretty simple script, I'd appreciate it :)
The original script is a .cmd file
@echo off
cd\
cls
subst o: c:\Windows
Exit
Basically the PS script would need to undo this for W7 machines.