Tag Info

New answers tagged

2

Mathias' answer is perfectly suited for the question as asked. A much better, more maintainable way to accomplish the goal, however, is to use a DHCP server with reservations.


3

If your txt file is just a space-separated list of [computername] [ip-address], you can use the Import-Csv cmdlet: $Computers = Import-Csv -Path C:\file.txt -Delimiter " " -Header Name,IP foreach($Computer in $Computers){ # Query $Computer.Name # Assign $Computer.IP as the static address }


0

The solution was to remove the default gateway from the configuration: DefaultGateway = '192.168.0.1' It appears that if there are any configurations in addition to the basic ones (IPAddress, InterfaceAlias, SubnetMask, AddressFamily), DSC will focus on the additional items and consider the basic ones as references. Consider the following: xIPAddress ...


1

So, there is no way to directly set up file permissions in a GPO using Powershell. (Computer/Policies/Windows Settings/Security Settings/File System) However, I was able to work around this by creating a GPO and manually backing it up (one time thing). In respect to the specific answer I was looking for, there are 3 files that need to be edited in the GPO ...


0

Windows is horrific. Freesshd seems to be the way to go for an SSH Daemon for Windows, and to get Powershell to work at all over SSH was the worst experience I have had with computers in a long time. In the end, with a suggestion from my coworker, this is how I solved it: Initially, I set this up as a Windows Task Scheduler job, and it was fine, but my ...


0

Use WinRM to invoke the script with the proper security context remotely SSH doesn't know how to delegate impersonation (nor should it) also use the scheduler built in to windows which can also invoke with the proper credentials.


2

You seem to have two different issues preventing you from doing what you want here - ExecutionPolicy and SysWOW64 File System Redirection. Bypass Execution Policy To bypass the execution policy, do so when launching PowerShell, like so: PowerShell.exe -ExecutionPolicy Bypass -File .\scriptname.ps1 Bypass File System Redirection Since freeSSHd seems ...


3

You should never configure your VM to Static Ip addresses inside the operating system, use azure portal or powershell instead. Configure a Static Internal IP Address for a VM: https://msdn.microsoft.com/en-us/library/azure/dn630228.aspx Basically you are telling the DHCP server to always give the same ip to your VM. If you don't want to use powershell, ...


1

Manual Configuration of network settings is not supported on Azure, which explicitly requires virtual network adapters to use DHCP, and resets this setting when an adapter is replaced (which usually happens each time the VM is shut down and deallocated). However, you can control which private IP address a VM gets by reserving a static IP, and which DNS ...


0

This worked for me to ADD a new manager (still need to know how to subtract a manager): $mgr = get-user gerald foreach ($thing in $things) { $group = Get-DistributionGroup $thing $managers = $group.ManagedBy $newmanagers = $managers+$mgr Set-DistributionGroup -BypassSecurityGroupManagerCheck -ManagedBy $newmanagers -Identity $thing }


1

You have to do in the computer configuration. Go to: Computer Configuration\Policies\Windows Settings\Security Settings\File System Right-click in the empty space in the right pane and choose "Add File". If whatever system you are on doesn't have the folder you want, you can create it in this file browser. After selecting the folder, assign the NTFS ...


0

I have found the answer: $oldpw = "oldpassword" $newpw = "newpassword" $user = $env:username $computer = $env:computername $user = [adsi]"WinNT://$computer/$user" $user.ChangePassword($oldpw, $newpw) This worked for me. Thank you for your replies!


0

I don't have enough points here to change it, but this question looks like a duplicate of this one.


0

I've noticed the problem: The destination user "osman" I was testing this on was a domain admin and apparently, domain admins do not inherit delegation (no idea why, not documented as far as I can see). All other non-admins work just fine! Thanks for all you suggestions.


0

There's no problem with using a self-signed cert for WinRM https, but when connecting to that computer's endpoint you need to specify that the (winRM) client should skip cert checks. You can do this using: $options = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck and then set up the session like this: $session = New-PSSession -UseSSL ...


0

See this answer on Stackoverflow (short answer - you cannot directly): http://stackoverflow.com/questions/5544844/how-to-call-a-complex-com-method-from-powershell


1

You can edit the original AD.msc and add functionality as you like. Here are some links: Custom AD console Right Click password reset Right Click Unlock Add additional columns


0

The only way I know of for a user to set their own password is this command. Set-ADAccountPassword -Identity $Name -Reset -NewPassword (ConvertTo-SecureString $Password -AsPlainText -force) -PassThru It will prompt them for their current password or if you leave out NewPassword it will prompt for both. If you are trying to give a helpdesk type person these ...


6

If these systems are members of an Active Directory domain you can use group policy to add a group of admin users to the Local Administrators group. If these systems are members of a domain but the users are local, you can use Restricted Groups to produce the desired effect. If these computers are not members of an AD domain you can use PowerShell to ...


2

If the end result is to replace "David" with "Gerald" as the owner, avoid the Add/Replace syntax altogether: Set-DistributionGroup Sales -ManagedBy "Gerald" If you must do these two operations atomically (if you have cases where you might not want to replace existing values), split it into two distinct operations: Set-DistributionGroup Sales -ManagedBy ...


2

From https://support.microsoft.com/en-us/kb/2019527 : The purpose of configuring WinRM for HTTPS is to encrypt the data being sent across the wire. WinRM HTTPS requires a local computer "Server Authentication" certificate with a CN matching the hostname, that is not expired, revoked, or self-signed to be installed. So you need to install a ...


0

$root = 'C:\logs' Get-ChildItem -Path $root | Where-Object { $.name -match "^\d*$" -and $.LastWriteTime -lt (Get-Date).Adddays(-45) } | Remove-Item -Recurse -Force


3

No - "Parallel" does not support a throttle limit I think you are confusing two distinct functionalities in PowerShell Workflows: Parallel (which is a Workflow Foundation keyword) -Parallel (a Workflow-specific parameter to the foreach loop) The Parallel keyword means: "Each of the following statements/sequences can be executed in parallel". So a ...


0

I use these great Subnet Math functions written by Chris Dent. Store your list of addresses in the pure decimal (not dotted decimal) or pure binary values. Sort the list, then retrieve the list, and finally display the list utilizing the ConvertTo-DottedDecimalIP function. Lots of other great subnet functions in his blog.


0

The code is off in a number of ways: If you are in a Windows Domain environment, why don't you just enable Powershell remoting via GPO? Enter-PSSession is a command for interactive remote sessions, what you are looking for is New-PSSession and Invoke-Command with the session parameter CredSSP is only required if you want to access remote systems from the ...


0

PSCredential encrypts the string using that machines private key. The encrypted data has the same level of protection at rest as it does in motion. The level of encryption is dependent upon the certificate being used, so check your environment's certificate template for machine auto enrollment (if you use it). Alternatively you could just look at the ...


2

That thread Tim linked has good info, here is a native way: (Get-Acl -Path "AD:\CN=John Doe,OU=Users,DC=contoso,DC=com" | ` select -ExpandProperty Access) | ` select ActiveDirectoryRights,IdentityReference With that, you should be able to get that into an Object and compare the user you're working as with -contains. Here are a couple blogs from Microsoft ...


1

I know this is an old post but I'd like to point out that the ForEach-Object cmdlet doesn't suffer the same issue as using the ForEach key word. So you can pipe the results of DIR to ForEach and just reference the file using $_, like: $backups | ForEach{ Remove-Item $_ } You can actually forward the Dir command itself through the pipe and avoid even ...


2

Easiest, native solution according to me. using powershell: Invoke-WebRequest http://your.url/path Save as test.ps1 and just invoke it. Then schedule it using task scheduler.


1

In Powershell 4.0 you can use requires at the top of your script: #Requires -RunAsAdministrator Outputs: The script 'MyScript.ps1' cannot be run because it contains a "#requires" statement for running as Administrator. The current Windows PowerShell session is not running as Administrator. Start Windows PowerShell by using the Run as ...


3

Presumably you're trying to format them this way so that they all show up nicely aligned. The only problem is that 020 isn't the same as 20. Not according to this anyway. Windows for Workgroups with TCP/IP-32 and Windows NT utilities can accept Internet Protocol (IP) addresses comprised of decimal, octal, or hexadecimal numbers. This can cause confusion ...


0

How locked down is your server from an access perspective? Who has access to the server and what can be done if someone does get that password? Most folks could read your script, figure out what the password is used for and ultimately utilize it for malicious purposes. Even if its encrypted. If it was me, I'd look at a few different options: If you ...


2

Install the Windows Update PowerShell Module, then run Get-WUList, it will take a while but will show you the required updates with their size. You can then use Get-WUInstall to download and install them.


2

From Preview Portal: Browse -> Virtual Machines -> Select VM -> All Settings -> Extensions -> Add -> Select Extension -> Create. Using Powershell: https://msdn.microsoft.com/en-us/library/azure/dn606311.aspx Each extension has different pre-requisites so it's not only a matter of installing the extension using powershell commands. Check the above list ...


1

To actually return an object of type Microsoft.ActiveDirectory.Management.ADOrganizationalUnit of a User Object, use this: Get-ADOrganizationalUnit -Identity $(($adUser = Get-ADUser -Identity $env:USERNAME).DistinguishedName.SubString($adUser.DistinguishedName.IndexOf("OU="))) The same can be accomplished for a computer: Get-ADOrganizationalUnit ...


0

When executing the script in the ISE or also in the console, everything runs fine. No errors or anything else that would stand out. Runs fine doesn't means there is no errors encountered. Your script probably just ignores them, using -ErrorAction SilentlyContinue parameter with cmdlets. Example: Get-ChildItem -LiteralPath ZZZ:\ This will generate ...


0

What else can I do to free up some space? Try Disk Cleanup first. Here is how to run it if you don't have Desktop Expirience installed, or don't want to install it. To run Disk cleanup: Click Start Click All Programs → Accessories → System Tools → Disk Cleanup Select Drive C from the drop-down menu Click OK


0

Try this. You can add any amount of folders, file types and file counts to the vairable $FoldersToCheck: # File to store log $LogFile = '.\FileCount.log' $FoldersToCheck = @( @{ Path = 'C:\path\to\folder' FileType = '*.cab' FileCount = 13 }, @{ Path = 'C:\path\to\folder\subfolder' FileType = '*.txt' ...


0

When you get an error do $error[0] | fl * -f You get a better stack and it gives you an idea of what was attempted. Looks like you maybe having issues authenticating to a web proxy in order to get to the Azure endpoint. What authentication does your web proxy (i assume its websense) support? I hope the proxy isn't set just for basic auth support. It ...


1

You don't have to be the global admin for an entire SharePoint Online deployment to upload files to a single library, so no, it can certainly be done


4

I think the problem might be with the way you're generating the credential using ConvertTo-SecureString. By default, that cmdlet uses an encryption key specific to the current host (I think) unless you provide an explicit encryption key with the -Key parameter. On the remote side, it needs to decrypt the string using the same encryption key which it ...


1

Find something else to delete first, like IIS logs.


1

unfortunately search-mailbox cmdlet is no longer available. not sure why they removed it. There is no option to recover ONLY recoverable items..


2

You can easily copy the contents of a file over-the-wire through a PSRemoting session using Invoke-Command and Set-Content: $Session = New-PSSession -ComputerName "remotehost.domain.tld" -Credential (Get-Credential) -UseSsl $FileContents = Get-Content -Path 'C:\path\to\arbitrary.file' Invoke-Command -Session $Session -ScriptBlock { ...


2

Get-Process won't get you anywhere. Assign the Count to a variable and test if the value of that variable is then 13: $cabFileCount = (Get-ChildItem -Filter "*.cab" "C:\path\to\folder").Count Write-Host $cabFileCount if($cabFileCount -eq 13){ # Success! Write-Host "$cabFileCount files found, perfect!" } else { # Failure! Write-Host ...


0

As of Windows 8.1 / Server 2012 R2, there are built-in PowerShell cmdlets for managing firewall rules, and netsh advfirewall has a message that it may be removed in a future version of windows. For this specific case: Get-NetFirewallRule -DisplayGroup "Remote Desktop" | Set-NetFirewallRule -Enabled True You can see the rest with: Get-Help *firewall* ...


0

Here is what works for me, using Powershell v4. PS C:\Scripts> Start-Process cmd -ArgumentList "/c 1.cmd" -WorkingDirectory c:\test4 Where 1.cmd lives in c:\test4


0

I'm not sure what exactly is the process behind the WebClient::DownloadFile method, but it seems to me that it interrupts the ftp connection right before the download transfer completes causing the operation to fail. By using the asynchronous method I managed to successfully download the file. Here's my updated function using the ...


0

Try using -erroraction silentlycontinue


1

This is due to the version of PowerShell you are running. This module runs with 2.0 ONLY. If you are getting the error run 2.0 by running "powershell.exe -version 2.0" Then import the module.



Top 50 recent answers are included