Powershell

17K

Solutions

7K

Contributors

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.

Share tech news, updates, or what's on your mind.

Sign up to Post

I want to make sure that WinRM services are running on my environment on few server. and also enable it if they are not running.
What is the best method to get a list of computers ?
0
Creating Active Directory Users from a Text File
LVL 8
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

I'm trying to apply a GPOPack with a Powershell script and missing something.  LGPO.exe is in C:\Software\GPOPack folder and I'm tryin to run lgpo /g c:\software\gpopack.  Works fine in CMD window but cannot get start-process variables or syntax correct.  Ex. Start-Process -FilePath 'C:\Software\GPOPack\lpgo.exe' -ArgumentList '/g C:\Software\' gets me
Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
At line:1 char:1
+ Start-Process -FilePath 'C:\Software\GPOPack\lpgo.exe' -ArgumentList  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
0
Hello,
       When trying to run a powershell script to change a local admin password I receive the following:
The following exception occurred while retrieving member "SetInfo": "Access is denied.

The account I am running the script under had domain admin access so I am a bit lost as to why this is happening..

Thank you for any help!
0
Hello experts,

I need to export the AD permissions granted to a group in AD. I need to find out what attributes has this group been permissioned to change.

For instance:

Group1,telephonenumber, write
Group1, password, reset

Thanks very much for your help.
0
Public Folder Migration from Exchange 2010 to Exchange Online (365)
With 45GB of Public Folders to migrate, how would you split up the Public Folder Mailboxes?

Are smaller mailboxes quicker?
Are too many mailboxes slower?

Is 1.9GB too small?
Is 4GB to large?

Thank you
0
Hi,

Is there a way to establish a powershell session to a server and use that session in a separate powershell process?

The powershell session I create will be authenticated using MFA and to stop using MFA for each and every powershell session that may be used in a script I would like to use a separate established connection.

I appreciate the security implications of this but would like to first find out if this is possible.

Any help would be greatly appreciated.

Thank you
0
Hello Gents

I want a Script Powershell script that can extract all the mailboxes and their sizes and  I want those datas in CSV format

Platform : Exchange 2013

Rgds
0
I need assistance in getting the below script to export to a csv? I tried using the | and export -csv at the end of the IF statement and it doesn't work? help lease


Import-csv "C:\fnfn.csv" | foreach{
    $UserName=$_.fn + "*"
    $lastName=$_.ln + "*"
    $user =Get-AdUser -filter{Name -like $UserName -and SurName -like $lastName} -Properties * | select *
   
    if($user){
        #all properties and fields are already in the $user if found, just need to filter whichever you need in here (or you can modify the $user 's variable select statement)
        $user | select Name,Surname,SamaccountName
0
We are currently on Exchange 2013 (Enterprise Version 15.0 Build 1365.1). I am trying to create a room resource that requires a booking delegate. I've created these in the past and with a little tweaking, I've been able to get them working successfully and the meeting notifications sent for that resource sent to the account's delegate where they have to accept/decline the meeting. However, I'm having no luck now. I have toggled the "AutomateProcessing" from None, to AutoAccept, to Autoupdate. Removed and replaced the delegate multiple times. I've compared the get-calendarprocess policy (shown in the attachment) to others that are working correctly and all the settings appear to be the same. The client wants a departmental calendar for users to put vacation time on but, must the events need to be approved by the calendar delegate. Any suggestions on this would be great.

Thanks,get-calendarprocessing info
0
Hi all,
I have following file Access-Logins-2018_05_20_Batch1.csv.gz and I need to know how do I unzip this zip file by using  powershell ? or can I achieve the same if I use SQL ssis package to unzip the file? After unzip this file going to load in sql server database
0
Introducing Cloud Class® training courses
LVL 12
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Guys.

I have following small  script in powershell to check all service running with name as  *sql* , In the output I have specify  4  columns which is  name,Displayname,status   comes from
get-service output, but the machinename was not there, how I do manage to get the output too from machinename ? and how many  more column  output like this  actually  that I can includes here  in my ps scripts ?

Get-Service -ComputerName  (Get-Content Servers.txt )| ?{$_.Displayname -like "*SQL*"}|select machinename,name,Displayname,status  | format-table -autosize
0
i can't remove things from windows 10 start menu.
i've tried removing xbox using powershell command, xbox is still in the start menu.
i can't find any link in the prgramdata folder to a program called hp jumpstart. yet it is in my start menu and i can't remove it.
how can i edit the windows 10 start menu?
0
Hello, I am a beginner in Python and I started about a week ago.  I would like to continue with Python, but there is a problem: I successfully added Python to path, so I could open MS Powershell and then type py to get started with some features like downloading modules with pip.  As I was told, I need to add pip to my path too and make a new environment variable. I copied the exact location of the file in this way C:\Users\Myname\Downloads\get-pip (get-pip was name of the file after download). I also tried C:\Users\Myname\Downloads\get-pip.py. Both of these options did not work. Then I thought that I didn't download it correctly. So I started as they wrote on their official website. https://pip.pypa.io/en/stable/installing/ After the first step MS Powershell showed me the following Error:
curl : Požadavek byl přerušen: Nelze vytvořit zabezpečený kanál SSL/TLS..
At line:1 char:1
+ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
I use Windows 10. I would be very pleased, if you would answer me. If any additional information is needed,just tell me , I will try to do my best to provide it.
0
Hi All,

I need a AzureAD or MSOL powershell script that assign office365 license to user based on user's group membership.

say, if user belongs to "msproject" group, then assign office365 project license to the user. the script will be scheduled run on a daily basic to scan all users and to make sure correct license are assigned based on group.

Any help would be much appreicated!

Thanks!
0
Searching for Ad group based on pattern
Dear,
I would like to use regex] to be able to search this
$strRegion = "Provence"
@(Get-ADGroup -Filter { name -like "$strRegion-??-full" } -Properties Description | Select Name,Description)


where ?? is a string of 2 char a-z.


who can help me to build this "easy" query ?
0
hello,
i use this command to send a print job to our printer for specific user

for that i use the username and password of user and psexec, after that the user can go to the printer and us his badge to print the document.

PsExec.exe -u domain\userName -p password cmd.exe /c print /d:\\printserver\Queue_color C:\print\test.txt

this is send a job to our printer, when i go to the printer to print this job, i see remote downlovel document for the file name, and printer wont print it.

in our old printer xerox, this is work, but with our new canon not work.

maybe you can suggest other simple way to print a document ? i test out-printer locally and it work, but i dont now if i can use it with psexec?

thanks for help
0
I need to create a powershell script to get all the roles on all the servers in a domain. there are 109 servers. I’m trying to get the script to create a separate csv for each server with its roles. so far I can get the script to either list all the roles on top of each other in 1 massive csv file or I can get it to create either blank csv files for each server or it will create csv’s with data that I have no idea where it came from. Here is my script:

Get-Content c:\servers.txt | Foreach-Object {{ Get-WindowsFeature Get-ADcomputer -filter * -properties "Name" $_ } | Export-Csv -Path "c:\$($_)_roles.csv" -notype}

Open in new window


I have a list of all the servers in a txt on the drive root. This script has to be able to function on a 2008 r2 box. Where am I going wrong?
0
$server = Read-Host 'Input Server name to check the Cluster'
            $Session = New-PSSession -ComputerName $server -Credential
                        Write-Output "Establishing connection with the server " $server
                  Invoke-Command -ScriptBlock { Import-Module FailoverClusters } -Session $Session
                  Write-Output "Checking cluster recources:"
                            Get-ClusterResource  | select ownernode,iscoreresource,name,resourcetype,state,characteristics | ft -auto


#------------code End-----------

Input Server name to check the Cluster: XXXXXXXservernameXXX
Establishing connection with the server
XXXServer nameXX
Checking cluster recources:
Get-ClusterResource : The term 'Get-ClusterResource' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and
try again.
At C:\Users\Cluster.PS1:11 char:29
+                             Get-ClusterResource  | select ownernode,i ...
+                             ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-ClusterResource:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


I am getting this error when trying to get the cluster node details from a Remote server. Seems like moduel is not getting installed. It work fine with out a script from my desktop and also from the remote server. But script is not working
0
Hello EE,

I have been researching the Sql server management Object ( smo) via powershell  . I wanted to simply 'generate scripts'  , output to screen similar to SSMS using the options Script "views" . "store procedures" and "User defined functions" . I found I can retrieve the views , sp, user defind functions using a foreach loop .

However, I wish to script a "drop and create" and a script " object level permissions" . Specifically from SSMS advanced options;

Option : Script DROP and CREATE                Value: Script DROP and CREATE
Option : Script Object-Level Permissions   Value:      True

I checked through the scripter options and had no luck so far , I have been using this link as a working example https://blogs.technet.microsoft.com/heyscriptingguy/2010/11/04/use-powershell-to-script-sql-database-objects/  , any help would be appreciated.

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("DB1")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("db_Test_Core")

$scrp = New-Object Microsoft.SqlServer.Management.Smo.Scripter($srv)
$scrp.Options.ScriptDrops = $FALSE
$scrp.Options.WithDependencies = $FALSE

foreach ($view in $db.Views){

$smoObjects = $view.urn
If ($tb.IsSystemObject -eq $FALSE)
   {
      $sc = $scrp.Script($smoObjects)
      Foreach ($st in $sc)
      {
      Write-Host $st
      }
   }
   }

Open in new window

0
Free Tool: Subnet Calculator
LVL 12
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I would like to use either a vb script or Powershell script to query a list of computers contained in a text file to find the following information:

1. Does the computer have Dropbox or Box installed? If yes, put computer name in first column of .csv file.
2. Put "Dropbox" or "Box" in second column
3. For the computers with Dropbox or Box, show the size of the Dropbox or Box folder
4. For the computers with Dropbox or Box, show the number of shared folders in the Dropbox or Box folder.

I don't need or want to see the names of the shared folders, just the number of shared folders for each computer.

Thanks,
Don
0
Dear Expert

Im going to scripting a file audit powershell script code is like this below:
Is there a easier way to write this? Like one variable $Path with all the folder path include instead create each path a $path variable?
$path1 = gc "\\srvp03\logs\log*"
$path2 = gc "\\srvp04\logs\log*"
$path3 = gc "\\srvp05\logs\log*"
$path4 = gc "\\srvp06\logs\log*"
$path5 = gc "\\srvp07\logs\log*"
$path6 = gc "\\srvp08\logs\log*"
$path7 = gc "\\srvp09\logs\log*"
$path8 = gc "\\srvp10\logs\log*"
$path9 = gc "\\srvp11\logs\log*"
$path10 = gc "\\srvp12\logs\log*"
$path11 = gc "\\srvp13\logs\log*"
$path12 = gc "\\srvp14\logs\log*"
$path13 = gc "\\srvp15\logs\log*"
$path14 = gc "\\srvp16\logs\log*"
$path15 = gc "\\srvp17\logs\log*"
$path16 = gc "\\srvp18\logs\log*"
$path17 = gc "\\srvp19\logs\log*"
$path18 = gc "\\srvp20\logs\log*"
$path19 = gc "\\srvp21\logs\log*"
if($path1 -ne $null){write-host "File in $Path1"}
if($path2 -ne $null){write-host "File in $Path2"}
if($path3 -ne $null){write-host "File in $Path3"}
if($path4 -ne $null){write-host "File in $Path4"}
if($path5 -ne $null){write-host "File in $Path5"}
if($path6 -ne $null){write-host "File in $Path6"}
if($path7 -ne $null){write-host "File in $Path7"}
if($path8 -ne $null){write-host "File in $Path8"}
if($path9 -ne $null){write-host "File in $Path9"}
if($path10 -ne $null){write-host "File in $Path10"}
if($path11 -ne $null){write-host "File in $Path11"}
if($path12 -ne $null){write-host "File in $Path12"}
if($path13 -ne 

Open in new window

0
I need to view the security settings on all the distribution groups in a certain OU to verify that authenticated users have read permission. I have tried to dump the acl's with the following in powershell.

foreach($group in Get-ADGroup -filter * -SearchBase "ou=distribution groups,ou=messaging,dc=yyyy,dc=xxx,dc=com" ){
get-acl $group
}

But I get the following error

get-acl : Cannot find path 'CN=zzzzzzzz,OU=Distribution Groups,OU=Messaging,DC=yyy,DC=xxx,DC=com' because it does
not exist.
At line:2 char:2
+ (get-acl -path $group).access
+  ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (:) [Get-Acl], ItemNotFoundException
    + FullyQualifiedErrorId : GetAcl_PathNotFound_Exception,Microsoft.PowerShell.Commands.GetAclCommand

When I run just

Get-ADGroup -filter * -SearchBase "ou=distribution groups,ou=messaging,dc=yyy,dc=xxx,dc=com"

I get the following

DistinguishedName : CN=zzzz,OU=Distribution Groups,OU=Messaging,DC=yyy,DC=xxx,DC=com

What am I doing wrong?
0
So I am trying to learn how to set IIS App Pools in Powershell, and also continue my training with Powershell.

I found somewhere that you can set the following attributes for the App Pool like this.

$appPool = Get-Item –Path IIS:\AppPools\XYZ_App_Pool
$appPool.processModel.identityType = "ApplicationPoolIdentity"
$appPool.enable32BitAppOnWin64 = 1
$appPool | Set-Item

Open in new window


I know I can do this to get a list of available options to set
Get-ItemProperty IIS:\AppPools\XYZ_App_Pool | select *

Open in new window


Output:
name                        : XYZ_App_Pool
queueLength                 : 1000
autoStart                   : True
enable32BitAppOnWin64       : True
managedRuntimeVersion       : v4.0
managedRuntimeLoader        : webengine4.dll
enableConfigurationOverride : True
managedPipelineMode         : Integrated
CLRConfigFile               : 
passAnonymousToken          : True
startMode                   : OnDemand
state                       : Started
applicationPoolSid          : S-1-5-82-2597519935-249327966-1169975569-694392190-3399998278
processModel                : Microsoft.IIs.PowerShell.Framework.ConfigurationElement
recycling                   : Microsoft.IIs.PowerShell.Framework.ConfigurationElement
failure                     : Microsoft.IIs.PowerShell.Framework.ConfigurationElement
cpu                         : Microsoft.IIs.PowerShell.Framework.ConfigurationElement
environmentVariables        : 

Open in new window

0
What is the command line command to set the Windows time and date according to an internet time server?
0
Hello,
 I am new to Powershell. I am looking for a script to perform an ftp upload.  I found the script below.   I made changes to the variable values. The variables values below are not mine.  

# Config
$Username = "FTPUSER"
$Password = "Passw0rd"
$LocalFile = "C:\Temp\file.zip"
$RemoteFile = "ftp://thomasmaurer.ch/downloads/files/file.zip"
 
# Create a FTPWebRequest
$FTPRequest = [System.Net.FtpWebRequest]::Create($RemoteFile)
$FTPRequest.Credentials = New-Object System.Net.NetworkCredential($Username,$Password)
$FTPRequest.Method = [System.Net.WebRequestMethods+Ftp]::DownloadFile
$FTPRequest.UseBinary = $true
$FTPRequest.KeepAlive = $false
# Send the ftp request
$FTPResponse = $FTPRequest.GetResponse()
# Get a download stream from the server response
$ResponseStream = $FTPResponse.GetResponseStream()
# Create the target file on the local system and the download buffer
$LocalFileFile = New-Object IO.FileStream ($LocalFile,[IO.FileMode]::Create)
[byte[]$ReadBuffer = New-Object byte[] 1024
# Loop through the download
      do {
            $ReadLength = $ResponseStream.Read($ReadBuffer,0,1024)
            $LocalFileFile.Write($ReadBuffer,0,$ReadLength)
      }
      while ($ReadLength -ne 0)

When I run I get the following error shown in the attachment Ftp Powershell errorwhich just keeps repeating.  I guess due to the loop.  The file does not transfer. Please let me know if any additional infomation is needed.
0

Powershell

17K

Solutions

7K

Contributors

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.