Quantcast
Channel: Windows PowerShell forum
Viewing all 21975 articles
Browse latest View live

Exchange 2010 hyper-v guest MaxEnvelopeSize error

$
0
0

Running the command below I receive the error below.  I have increaced the MaxEnvelopeSize on the IIS system.webServer/system.management.wsmanagement.config

and still I am getting the error. 

Any ideas?

$Configuration = Get-SenderFilterConfig

$Configuration.BlockedSenders += "Fenjeobyh@xxxxxxxxx.com"

Set-SenderFilterConfig -BlockedSenders $Configuration.BlockedSenders

Starting a command on remote server failed with the following error message : The WinRM client sent a request to the re
mote WS-Management service and was notified that the request size exceeded the configured MaxEnvelopeSize quota. For mo
re information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OperationStopped: (System.Manageme...pressionSyncJob:PSInvokeExpressionSyncJob) [], PSRe
   motingTransportException
    + FullyQualifiedErrorId : JobFailure
    + PSComputerName        : mail.xxxxxx.com

PS C:\Users\administrator.FMEW> Set-Item WSMan:\localhost\MaxEnvelopeSizekb 500000
PS C:\Users\administrator.FMEW> winrm g winrm/config
Config
    MaxEnvelopeSizekb = 500000
    MaxTimeoutms = 60000
    MaxBatchItems = 32000
    MaxProviderRequests = 4294967295
    Client
        NetworkDelayms = 5000
        URLPrefix = wsman
        AllowUnencrypted = false
        Auth
            Basic = true
            Digest = true
            Kerberos = true
            Negotiate = true
            Certificate = true
            CredSSP = false
        DefaultPorts
            HTTP = 5985
            HTTPS = 5986
        TrustedHosts
    Service
        RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GWGX;;;WD)
        MaxConcurrentOperations = 4294967295
        MaxConcurrentOperationsPerUser = 15
        EnumerationTimeoutms = 60000
        MaxConnections = 25
        MaxPacketRetrievalTimeSeconds = 120
        AllowUnencrypted = false
        Auth
            Basic = false
            Kerberos = true
            Negotiate = true
            Certificate = false
            CredSSP = false
            CbtHardeningLevel = Relaxed
        DefaultPorts
            HTTP = 5985
            HTTPS = 5986
        IPv4Filter = *
        IPv6Filter = *
        EnableCompatibilityHttpListener = false
        EnableCompatibilityHttpsListener = false
        CertificateThumbprint
    Winrs
        AllowRemoteShellAccess = true
        IdleTimeout = 180000
        MaxConcurrentUsers = 5
        MaxShellRunTime = 2147483647
        MaxProcessesPerShell = 15
        MaxMemoryPerShellMB = 150
        MaxShellsPerUser = 5


Powershell galleries

$
0
0
Hi,

Has anyone managed to get the internet access from Powershell v5 for the Powershell gallery to work, typically with nuget based repositories? If yes, please share how you did.

This is what I see:

"WARNING: Unable to download the list of available providers. Check your internet connection."

Internet access is there from the machine when browsed from Internet explorer

Thanks

Abbreviation for long Enum names

$
0
0

Hallo,

I'm often using PowerShell for Excel automation and therefor I make use of Excel's enumerations like

[Microsoft.Office.Interop.Excel.XlFileFormat]
[Microsoft.Office.Interop.Excel.XlBorderWeight]

and so on. Since these enumeration names are quite long and mostly the same, I wonder if there is a possible abbreviation method. Something like

$xlenum = "Microsoft.Office.Interop.Excel"
[$xlenum.XlFileFormat]

Do you have any ideas?

Best regards

Christoph

Create a script to grab Share names and permissions

$
0
0

I do OK at powershell but am struggling with this and do not know why.  I need a script to search a Win 2012 R2 file server get all the shares and share permissions on it.

I am using Get-WmiObject -class win32_share and it gives me all the shares.

I take the output and I use it in Get-ChildItem <sharename> |Get-Acl |fl this shows the permissions under Access.

Path   : Microsoft.PowerShell.Core\FileSystem::C:\Users\tmpuser\Downloads\EMC grab\HostGrabs\EQR-DR-ESX03_2016-02-05-07.21.07_ESXi_emcgrab_full_CC0000000000.zip
Owner  : BUILTIN\Administrators
Group  : mydomain\Domain Users
Access : NT AUTHORITY\SYSTEM Allow  FullControl
         BUILTIN\Administrators Allow  FullControl
mydomain\tmpuser Allow  FullControl

I am good just Export to a csv and I am done.  So I add | Export-csv C:\filepath\filename.txt 

When I get the output it doesn't show the share permissions?

I get the PSpath,Owner,group but access shows "System.Security.AccessControl.AuthorizationRuleCollection"

I can not get around this.  Can anyone please help me.  Also please keep it simple I am just OK at PS.

Thanks,

Use a file name as a argument

$
0
0
I currently have a powershell script that runs with a user entered argument.  I would like to actually have it read a file name, minus the extension, and run the script with that file name.  So currently I have to run it like this powershell.ps1 S1612345 and it will do its magic.  However I created a button on our website to create a file with the S1612345 file name in a certain directory and I want to set powershell to monitor that directory for the file name, run the script with the file name and then delete the file from that directory.  Can anyone help me please?  Thank you

Using file name as an argument

$
0
0
I currently have a powershell script that runs with a user entered argument.  I would like to actually have it read a file name, minus the extension, and run the script with that file name.  So currently I have to run it like this powershell.ps1 S1612345 and it will do its magic.  However I created a button on our website to create a file with the S1612345 file name in a certain directory and I want to set powershell to monitor that directory for the file name, run the script with the file name and then delete the file from that directory.  Can anyone help me please?  Thank you

Using split to replace last octet in IP

$
0
0

I'm using windows forms pipe out information. I have a function that gathers information from a SCOPE ip and when it reads the SCOPE IP it takes off the last Octet and replaces it with a .1 for the gateway.

When I enter 10.10.10.0 The "return" text field is returning 10 10 10 1 . I'm not sure why it's stripping out the decimals.. any ideas?

function Gtway {

$ip = $inputbox6.Text
$ip2 = $ip.Split('.')
$ip2[-1] = 1
$ip2 -join '.'
$inputbox9.text = $ip2
}

Change/Calculate value in CSV file

$
0
0

Hi,

I have a CSV file with this structure

(Initially the Column4 is empty and presented values have to be calculated with PowerShell)

Column1 Column2 Column3 Column4
Name1 001 25 Name1 001 25;Name1 01 25;Name1 1 25;Name1 001/25;Name1 01/25;Name1 1/25
Name2 085 30 Name2 085 35;Name1 85 35;Name1 85/35;Name1 085/35
Name3 191 35 Name3 191 35; Name3 191/35
 

Based on the first three column I have to build the last one, in such a way to have all possible values separated by space or /.

As can be seen, the second column have numeric values. These have to be represented in column 4 with all their possible values:

- for 001: 001, 01 and 1

- for 085: 085 and 85

- for 191: 191

Initially, in the CSV file the Column4 is empty.

How can I fill in those values in Column4 using PowerShell?

Thanks in advance for any suggestion.


OvidiuG



Windows 10 Powershell HasMoreData incorrect

$
0
0

I have been using powershell and the HasMoreData for a long time with Win 7 and Win 8.

Well i just started putting Win 10 out in the wild and started getting false positives. Turns out my HasMoreData is flipping to True when it does not on the older Windows

I tested a bit more but it doesn't ALWAYS flip. Can someone explain whats going on?

This comes back as HasMoreData False

Invoke-Command -cn CPUABC -asjob -ScriptBlock {if (!($true)){write-host $env:COMPUTERNAME}}

This Comes back as HasMoreData True, even if $value is not wrote to console

Invoke-Command -cn CPUABC -asjob -ScriptBlock {$value = (Get-Counter "\LogicalDisk(c:)\% Free Space").countersamples | Select -ExpandProperty CookedValue;if ($value -lt 15){$value}}

Once again this does not happen on win7 and win 8

Get samaccountname from display name - bulk csv

$
0
0
I have a csv file with AD users' display names. Does anyone have the script to get samaccountnames from such csv?

Ad-Domain-Services Post Configuration Message.

$
0
0

I can Install Ad-Domain-Services feature with the add-WindowsFeature cmdlet.

Then we can go in server manager and see warning message saying that the server need post-configuration and the server need to be promoted to a DC.

I can find more information on this using PowerShell.  I use

(Get-WindowsFeaturead-domain-services).PostConfigurationNeeded).

Is there a way in PowerShell to retrieve this warning message that we see in server manager?

Thank.


David

Excluding multiple groups from a report in AD using PowerShell

$
0
0

I'm extremely new to PowerShell, and I'm attempting to pull a list of inactive users, but I want to exclude (currently 6) groups from this report.I admit that this is a mess, but it's the progress I've made so far:

get-aduser -server accounts -filter * -properties SamAccountName, Description, PhysicalDeliveryOfficeName, lastLogonTimestamp, passwordlastset, lastlogondate, Enabled | Where-Object {($_.Memberof -NotContains "Do_Not_Disable*") -or ($_.Memberof -NotContains "POL_XXX") -AND ($_.passwordlastset -le $84days) -AND ($_.LastLogonDate -le $84days) -AND ($_.Enabled -eq $True)} | Select SamAccountName, Name, Description, PhysicalDeliveryOfficeName, lastLogonTimestamp, passwordlastset, LastLogondate, Enabled |sort SamAccountName, Enabled, Name, Description, PhysicalDeliveryOfficeName, lastLogonTimestamp, passwordlastset, LastLogondate, WhenCreated| Export-csv C:\Temp\20160216_NotGroupMembers1.csv

For some reason, no matter what I try to do to exclude these groups, they invariably still pop up on this report. Once I figure this out, I will be using this to actually disable users, but I wanted to be able to look at the data, and see it pulling the information reliably before actually making changes to my domain. Thank you for any assistance that can be provided.

Powershell Variable Storage limit

$
0
0


Hi

I am trying to use the below powershell script to download an attachment from my o365 email address. The size of the attachment is 9mb. The script is able to read the message and attachment but unable to store the data of attachment to $attachments variable.  However, there is no such issue when i use a smaller file (size < 1mb).

Is there any store limitation on powershell variables? if so, then what is the work around available here with us.

##-----------------------------------------------------##
##        PICK AUTH Method                             ##
##-----------------------------------------------------##
 
## HARD CODING PSW    ##
#$password = ConvertTo-SecureString "xxx" -AsPlainText -Force
#$cred = New-Object System.Management.Automation.PSCredential "xxx@xxx.onmicrosofot.com",$password
 
## USER PROMPT PSW    ##
#$cred = Get-Credential
 
##-----------------------------------------------------##
##    END PICK
##-----------------------------------------------------##
 
$url = "https://outlook.office365.com/api/v1.0/me/messages"
$date = "2014-11-21"
 
## Get all messages that have attachments where received date is greater than $date  
$messageQuery = "" + $url + "?`$select=Id&`$filter=HasAttachments eq true and DateTimeReceived ge " + $date
$messages = Invoke-RestMethod $messageQuery -Credential $cred
 
## Loop through each results
foreach ($message in $messages.value)
{
    # get attachments and save to file system
    $query = $url + "/" + $message.Id + "/attachments"
    $attachments = Invoke-RestMethod $query -Credential $cred
 
    # in case of multiple attachments in email
    foreach ($attachment in $attachments.value)
    {
        $attachment.Name
        $path = "c:\Temp\" + $attachment.Name
     
        $Content = [System.Convert]::FromBase64String($attachment.ContentBytes)
        Set-Content -Path $path -Value $Content -Encoding Byte
    }
}
 

Regards

Jasneet

Tasks based on user selection - simplified

$
0
0

I'm curious what would be the best way to accomplish the following:

A admin is presented with a multiple selection box (i.e. select what products you want 1,2,3,4,5,6)

admin selects 1,2  & 3 and its written to a simple txt file so get-content of txt file would show 1,2,3

Each option would have a AD OU attached to it, so option 1 will need a AD OU a,b,c where a,b and c is a corresponding Organizational Unit ; Option 2 will need a AD OU d,e,f  where d,e and f is a corresponding Organizational Unit.

Later on I need to perform tasks based on the options selected. So if 1 was selected, do this; if 2 is selected do this etc.

I know I could do multiple If statements but was wondering if there was a more efficient method? Maybe, make a comprehensive array based on all the options. So the below $distinguishednames array would cover all possible requirements and then I could do the "do this" section once instead of doing multiple If's.

So the current way would look like the below:

If($selection -contains "1") $distinguishednamea = get-adorganizationalunit -filter 'name -eq "name"' | select-object -expandproperty distinguishedname $distinguishednameb = get-adorganizationalunit -filter 'name -eq "name"' | select-object -expandproperty distinguishedname $distinguishednamec = get-adorganizationalunit -filter 'name -eq "name"' | select-object -expandproperty distinguishedname $distinguishednames = $distinguishednamea,$distinguishednameb,$distinguishednamec

ForEach ($distinguishedname in $distinguishednames) do this #This task is the same task just has to use the unique $distinguishednamesa,b,c etc

If($selection -contains "2")
$distinguishednamed = get-adorganizationalunit -filter 'name -eq "name"' | select-object -expandproperty distinguishedname
$distinguishednamee = get-adorganizationalunit -filter 'name -eq "name"' | select-object -expandproperty distinguishedname
$distinguishednamef = get-adorganizationalunit -filter 'name -eq "name"' | select-object -expandproperty distinguishedname

$distinguishednames  = $distinguishednamed,$distinguishednamee,$distinguishednamef

ForEach ($distinguishedname in $distinguishednames)

do this #This task is the same task just has to use the unique $distinguishednames d,e,f etc




add more than 2 WINS addresses using powershell

$
0
0
I need to modify the WINS on around 350 servers. I have tested a powershell script to add WINS addresses to servers using WMI, with the setwinsserver(primary, secondary) method. The issue is, WMI is coded to only allow primary and secondary WINS. I need to add 4 WINS addresses. I expect that -I need to do the registry -I also need to identify which registry entry has existing WINS entries and modify that, as there are multiple adapters with non standard names.

PowerShell DSC "Reporting Server" Question

$
0
0

So I have setup a simple DSC server in my lab.  It's an HTTPS Pull server w/ several clients.  I can create configs(MOFS) and push them out to clients and everything seems to be working.  My issue is with the Reporting Server (formally compliance server)  I cant seem to browse the website like they describe in this article.  

https://blogs.technet.microsoft.com/privatecloud/2014/08/08/desired-state-configuration-dsc-nodes-deployment-and-conformance-reporting-series-part-3-working-with-the-conformance-endpoint/

I kept getting an Access Denied message.  I did some looking and I came across a blog that said that they had to turn off Windows Auth and enable Anonymous which I did but am now getting a different access denied message.(See Below)  I am using the newest WMF on Windows Server 2012R2.  I just want to query the site to see if clients are reporting status?

Thanks for your help!

TotalItemSize help

$
0
0

Hello,

Can somebody complement me in this script. I need to get the TotalItemSize in the export.

Get-Mailbox |
?{$_.ExchangeUserAccountControl -eq 'AccountDisabled'} |
ft Name,Database,ExchangeUserAccountControl |
Out-File "location"


Users home Folder bulk transfer from one server to another

$
0
0

Hello,

I'm facing a disk space issue on my file server, so I'm trying to move the home folder for disable users (over 200) from one server to another server ( used to hold disabled users folders for a certain time).

- I have two servers source and backup

- I extract the list of the disabled accounts to a CSV file (disabled.csv)

- I tested with one account using the powershell command (copy-item), it works fine.

I'm new to Powershell, I want to know how can I do it for the whole accounts once.

I understand that I need to read the file through a loop (for each...), but i dont know how to construct it.

thank you very much for your help

Difference between Remove-Item in Powershell 3.0 and 4.0

$
0
0

Hi! Just a simple question

Seems that there is a difference between PS version 3 and 4 running this command, because in PS 3 it leaves the content in the GetFoldersizePortable (which is a folder) and in PS 4 it doesnt

Remove-Item -Path 'C:\temp\*' -Recurse -Exclude WindirStat.exe, GetFoldersizePortable

My question is why, and how to work around this


Get page load time through powershell

$
0
0

Hello,

I am looking for to get the page load time through PowerShell. The data  which i am looking for is Load (event) in IE developer tools Timings section. Reference: https://msdn.microsoft.com/en-us/library/dn255004(v=vs.85).aspx

I can get the Response Header details by using below commands; however couldn't find any PowerShell parameters to get the load time.

       

$WebRequestObject = [System.Net.HttpWebRequest] [System.Net.WebRequest]::Create($URL);
$WebRequestObject.UseDefaultCredentials = $true;
$WebRequestObject.PreAuthenticate = $true;
$ResponseObject = [System.Net.HttpWebResponse] $WebRequestObject.GetResponse();
foreach ($HeaderKey in $ResponseObject.Headers)
{
$HeaderStr = $ResponseObject.Headers[$HeaderKey];
if ($HeaderStr)
        {
Write-Host "$HeaderKey`: $HeaderStr";
}
}

I found another commands, which gives the DownloadString timings; however it won't match with actual page load times.

$Request = New-Object System.Net.WebClient
$Request.UseDefaultCredentials = $true
$PageRequest = $Request.DownloadString($PageURL)

Let me know, if any powershell commands available to fetch the page load time through the web request (which is similar to IE developer tool data).

Thanks,

Anoop

Viewing all 21975 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>