Hot answers tagged

5

2 ways so far: canonical name: get-adgroup -identity "your group" -properties canonicalname | sel -property canonicalname [enter] canonicalname Your.Domain/ou name/ou name/your group using the distinguishedname: $group = get-adgroup identity "your group" [enter] ($group.DistinguishedName -split"," ,2)[1] [enter] ou=name,ou,name,dc=your,dc=domain,dc=...


4

What you need to do is: Get the original rule by name Get the address filter out of it Get the new rule by name Set the address filter in it And yes, you can merge a lot of those into a one-liner, but for example I think this will do it: $sourceRule = Get-NetFirewallRule -DisplayName "MSSQL" $sourceIPs = $sourceRule | Get-NetFirewallAddressFilter Set-...


4

No, not as you asked the question. This info is not in Active Directory, sorry to say. You could however write some PowerShell, starting with Get-ADComputer likely with a filter to just get server operating systems, and then pipe or loop that into either WMI or Registry queries to get the list of installed software - and hopefully the version info you want ...


3

You want the LastWriteTime property. You could see my somewhat recent answer here using this property to basically write your script. Based on modifying that (but not testing it), something like: $searchroot="[root path you're searching in]" $age=(get-date).AddDays(-60) Get-ChildItem $searchroot | where-object {$_.LastWriteTime -ge $age } | ForEach-...


3

You can peruse existing script https://gallery.technet.microsoft.com/scriptcenter/Get-RemoteProgram-Get-list-de9fd2b4 To get a list of computers that have Internet Explorer 11: $result= @(); $programName = "Internet Explorer 11" $computers = ("Computer1","Computer2","Computer3") $computers | % { if ((Get-RemoteProgram -ComputerName $_).programname -...


3

Before you start running network scanners on your network, have you actually asked your coworkers for any documentation, wikis, email chains, etc that might give you a better clue? Assuming no one knows anything and you're on your own. The first thing I'd do is a reverse DNS lookup on the IP that the URL maps to. If the public URL is a friendly name and ...


3

When using Read-Host you are getting a string and the KB/GB operator are not handled in the same way as when an integer is expected. You need to convert your input to an integer like: [int]$MinimumBytes = Invoke-Expression (Read-Host -Prompt 'Dynamic Memory Minimum') [int]$MemoryStartupBytes = Invoke-Expression (Read-Host -Prompt 'Memory Startup Bytes') ...


2

Tested the below on a PC successfully: dism.exe /online /Remove-Package /PackageName:Microsoft-Windows-InsiderHub-Package~31bf3856ad364e35~amd64~~10.0.10586.0 I got the packagename from the DISM cmd switch get-packages: dism /online /get-packages > getpackages.txt


2

In general a xcopy deployment of PowerShell modules is possible, just copy the files. You don't even have to use $env:ProgramFiles\WindowsPowerShell\Modules, put them anywhere you like, as long as you have that location in $env:PSModulePath. But this will only work if the module uses only PowerShell code files and .NET assemblies. There may be modules that ...


2

have you tried something like this : Get-EventLog -logname security | Where-Object {($_.eventid -eq 1936) -or ($_.eventid -eq 1937) -or ($_.eventid -eq 1938)} | export-csv -path c:\temp\events


2

32-bit Powershell requires 32-bit Outlook objects and 64-bit powershell requires 64-bit Outlook. So yes, you do need an Outlook installation to run the script. Edit: Actually, you require the MAPI (Mailing API). Which comes with Outlook. If you have an SMTP server available, you could use Send-MailMessage as described here


2

You can try this put the list of servers on text file or filter from AD #$computer="get-content computers.txt" #computers=Get-ADComputer -Filter {OperatingSystem -Like “Windows Server*”} foreach ($Computers in $computer) { Get-WmiObject -query 'select * from win32_product' | where {$_.name -like "Ccleaner*"} |ft Name, Version,PsComputername | export-csv "$...


2

In the FOR command you need escape not only the parenthesis, but the mod (percent) as well. The parens are escaped with ^, the percent by %. Note that this will only work within a batch file, not the command line. FOR /F %%i IN ('powershell ^(new-timespan -start 01/01/2000 -end ^(get-date^)^).days %% 14') DO ( SET doc=%%i ) ECHO %doc%


2

All of the pagefile parameters are stored in the registry. Have your script manipulate the values in the following key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management For instance, the PagingFiles entry is a multi-valued string, with each different paging file on a separate line. The numbers following the filename ...


2

That error is caused by some cmdlet or command in your script (showing the parameters is a red herring). Look for Write-Host, Remove-Item et similia. You can try executing your script passing the -NonInteractive flag to the Powershell interpreter or experiment different values for the $ConfirmPreference variable (e.g. None).


1

This will wait until the VM is running: while ((get-vm -name $vmnames).state -ne 'Running') { start-sleep -s 5 } And this will wait until the VM is off: while ((get-vm -name $vmnames).state -ne 'Off') { start-sleep -s 5 }


1

I finally did it using PowerShell. Thanks to the following TechNet posts Exchange 2007 GUID Reference and Update ACL Skeleton I was able to delegate control of the TestUsers organizational unit to a user NickA and give the permissions that I originally posted. $OU = Get-ADOrganizationalUnit -Identity "OU=TestUsers,DC=contoso,DC=private" $SID = new-object ...


1

I haven't tackled ACL building with PowerShell yet, but this can be done with the old DSACLS command that has been part of RSAT and the Support Tools since Windows Server 2003. dsacls "OU=Test,DC=domain,DC=com" /I:S /G "domain\user:CA;Reset Password";user Put the DN of the delegated OU in between the quotes and put the user after the /G (grant) parameter. ...


1

There is an example here of downloading a zip file using PowerShell on Nano, you might have to modify it a bit for your purposes; (from here: https://docs.asp.net/en/latest/tutorials/nano-server.html#installing-the-asp-net-core-module-ancm) $SourcePath = "https://dotnetcli.blob.core.windows.net/dotnet/beta/Binaries/Latest/dotnet-win-x64.latest.zip" $...


1

Try the following syntax: xWebApplication StaffDirectoryApp { Website = "MySite" Name = "MyApp" WebAppPool = "MyPool" PhysicalPath = $Destination Ensure = "Present" PreloadEnabled = $true AuthenticationInfo = MSFT_xWebApplicationAuthenticationInformation { Anonymous = $false ...


1

$Users=Import-csv c:\users.csv $failedUsers = @() $usersAlreadyExist =@() $successUsers = @() $VerbosePreference = "Continue" $LogFolder = "C:\temp" ForEach($User in $Users) { $FullName = $User.FirstName + " " + $User.LastName $SAM = $User.FirstName.Substring(0,1) + $User.LastName $dnsroot = '@' + (Get-ADDomain).dnsroot $UPN = $SAM + "$dnsroot " ...


1

Add the RegistryKey : MigrateNormalOnFirstBoot = 1 Customization to the Normal template is lost after you upgrade to Word 2013 This issue occurs because Word creates a new Normal.dotm file when you upgrade to Word 2013. This is so that the default document template is optimized for Word 2013. Resolution To resolve this issue, add the ...


1

You can do anything with PowerShell! For instance, the following function can open a Word document: $FileName='C:\Users\UserName\AppData\Roaming\Microsoft\Templates\YourDocument.dotm' $Word = New-Object –ComObject Word.Application $Document=$Word.Documents.Open($Filename) And save, then close it: $Document.SaveAs([REF]$FileName) $Document.Close() After ...


1

You cant change that value, its protected. The only value you can manually put is 0 or -1. 0 will force a user password change (as like expired), -1 behave like the password will not expire.


1

I was able to reproduce the issue with Update 2 using a local/non-domain account. LDAP did not work, GC does work. I'm not sure why. If it is only this query that is failing, perhaps using GC would be an acceptable workaround. The same query using a regular .NET application does not fail. I did notice the following in the Netlogon.log but I don't think ...


1

The share and the share permissions are set on MainShare. If you want share permissions on \FooBar\MainShare\SomeStuff\MyTarget then you would have to create a new share point directly to that folder


1

The error indicates that the certificate used on the end point you are trying to connect to is an un-trusted certificate. I recommend ensuring that a valid and trusted certificate is used on the endpoint. However if this is not possible you can set PowerShell to allow un-trusted certificates once per session with this function. However be warned that ...


1

Yes and no. If you are running Windows 10 or Server 2016 and newer the Microsoft.PowerShell.LocalAccounts module is available for use. However on Windows 8.1 or Server 2012 R2 and older you'll still have to use the old methods for local account administration event if you update to PowerShell 5 or later.


1

Make sure the Deduplication module is imported in Powershell, otherwise the commands will not be available: Import-Module Deduplication


1

Due to how Windows handles authentication it is not possible to use CMDKEY to set credentials via a remote PowerShell session, it has to be done interactively when using CMDKEY. To quote Don Jones from a thread looking for an answer similar to yours: That's a limitation of the Cmdkey command – not really a PowerShell thing. But it's related to the way ...



Only top voted, non community-wiki answers of a minimum length are eligible