I wrote a script that manages services on the server and starts/stops etc...depending on the Task in the csv file, as well as changes the startuptype, again depending on the start up type in the csv file. CSV file: > Server,Service,Startup Type,Task > server1,SQL Server Analysis Services (MSSQLSERVER),automatic,start > server2,"SQL Server Analysis Services (MSSQLSERVER), SQL Server Analysis Services (MSSQLSERVER) CEIP",Manual,stop Script $csvFile = Import-CSV .\SSAS_services.csv $ServiceState = Get-Service -Name $ServiceStartupType = Get-Service | select -property name,starttype ForEach ($row in $csvFile) { #checking if service in csv file exists on server if (Get-Service $row.Service | Select-Object Name, StartType, Status -ComputerName $row.Server …

Member Avatar
Member Avatar
+0 forum 1

I would like to be able to open a port on windows programatically. I don't care whether is power shell, or something else, but I would like it to be a script that I can simply run as I install a software program. I have no experience in this area, and therefore no code, but I hear net admins do this all the time. Thanks ahead of time. I know people don't necessarily like sharing code, but I am on a tight deadline right now, and it is in fact necessary. I have some other code I need to be …

Member Avatar
Member Avatar
+0 forum 1

I have a table that contains some cubes with servers and active status (see attached image): note: CUBE1 is repeated intentionally. The idea is the same cube is getting synced from the same server 1 as a data source (process_server) onto different target servers (query_server; say server2 is in region A and server 3 is in region B). The way the environment is set up is both servers have to be active/active status (meaning TRUE) except for some additional test cases, i am setting to false sometimes one or the other. I have the following script now calling the cube …

Member Avatar
Member Avatar
+0 forum 1

I have a powershell script from PRTG that will ssh into a juniper device and allow me to exicute a command. I am trying to run "Request System Storage Cleanup" which works but the problem is the session asks for conformation of the clean up. Adding a carriage return and then yes in the same line does not work nor did adding another command. I cannot use "Request system storage cleanup no-confirm" due to the firmware is not new enough. Any suggestion on how to confirm the command? `param( $Computername = "", $Username = "", $Password = "", $Port = …

Member Avatar
Member Avatar
+0 forum 1

Hi all, I'm trying to replace text in a CSV. The CSV line looks something like this: "Field One","Field Two","Field Three","Field Four" So I tried something like: (Get-Content $csvfile) -replace "Field`n", "Field" | Set-Content $csvfile

Member Avatar
Member Avatar
+0 forum 2

I have a oracle query and i would like to run it by powershell using ODP.Net. Below is the query. set pagesize 100 set linesize 200 break on report compute sum of free_mb on report compute sum of act_size on report compute sum of used_mb on report col %used format 999.99 col %Free format 999.99 col act_size format 99,99,999.99 col free_mb format 99,99,999.99 col used_mb format 99,99,999.99 col file_name for a60 col largest_extent_MB format 99,99,999.99 col tablespace for a25 select SUBSTR(a.tablespace_name,1,20) "TABLESPACE",act_size,free_mb, free_mb*100/act_size "%FREE", act_size-free_mb used_MB,((act_size-free_mb)*100)/act_size "%USED",largest_extent_MB from (SELECT TABLESPACE_NAME,SUM(BYTES)/1024/1024 FREE_MB, max(bytes)/1024/1024 largest_extent_MB FROM DBA_FREE_SPACE group by tablespace_name) a, (SELECT …

Member Avatar
+0 forum 0

I have a powershell script in that script i am using datagridview. My script is working fine. All looks ok to me. My issue is i want to get the first column value of selected row. To fulfill this i need to add event (cell click/cell content click/cell mouse click). I am not able to figure it out. How to add event. Can somebody please advise me on this? $datagridview1_CellMouseClick = [System.Windows.Forms.DataGridViewCellEventHandler]{ write-host $_.RowIndex # This displays the row number selected write-host $_.ColumnIndex # This displays the column number selected write-host $datagridview1.Rows[$_.RowIndex].Cells[0].value # This would display the value of the …

Member Avatar
+0 forum 0

Hello all, The issue I am having involves a user that uses a CAC to log in to a network. When the account is created, a 10-digit number printed on the CAC is associated with the users account and replaces their User Logon Name in ADUC. This users number was incorrectly applied to another account, but with thousands of users its practically impossible to search everh one of them one by one. I am attempting to use Powershell to search by UPN to identify the account that has the number associated incorrectly, but I am only finding syntax that set …

Member Avatar
Member Avatar
+0 forum 2

Hi Everyone, Wanted to share a bit on this subject as I've had to recently make some of these changes. Along my way I found a few sites that basically suggested moving all mailboxes off the database, dismount, delete and create a new database. Simple enough, however I didn't want to do this. As you may or may not know, by default Exchange installs the database at the following location: C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Database1\Database1.edb Log files would go: C:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Database1 What if you wanted to change the location or name of those files? Well thankfully this is super easy with …

Member Avatar
+0 forum 0

Hi guys, I have some C# code in my Powershell script and in that code I have a global variable. How can I access my variable from the powershell code ? $source = @' using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; public partial class Form1 : Form { Object nodes2 = new Object(); } '@ $assemblies = ('System.Windows.Forms','System.Drawing','PresentationCore','WindowsBase','System.Xml') try { Add-Type -TypeDefinition $source -ReferencedAssemblies $assemblies -ErrorAction STOP (New-Object Form1).Showdialog() | Out-Null } catch { Write-Warning "An error occurred attempting to add the .NET Framework class to the PowerShell session." Write-Warning "The …

Member Avatar
Member Avatar
+0 forum 1

Hey, DaniWeb! I need your opinions. I'm looking to expand my skillset, particularly in the Windows department. On a scale of "Eh, maybe later" to "Do it! Do it now!" what is your opinion on the importance of learning PowerShell as opposed to another life skill like Haskell, Mandarin Chinese, or subtropical gardening? Or if you have other suggestions, I'm open to them.

Member Avatar
Member Avatar
+0 forum 2

I'm currently pulling out information from column B in an Excel worksheet + the worksheet name. How would I go about pulling information from column J (which has the same start row/end row as the information pulled out from column B) in the same worksheet and assigning it to the object property $apps.location? I've done a bit of research on the internet, but there doesn't seem to be a straightforward method of accomplishing this. $(for ($i=3; $i -le $wb.sheets.count; $i++){ $sh=$wb.Sheets.Item($i) $startCell_appname = $sh.cells.item(1,2).EntireColumn.find("Application Name").Address() $startCell_appname = [regex]::replace($startCell_appname, '(\$\w+\$)(\d+)', {param($m) $m.groups[1].value + ([int]$m.groups[2].value+1)}) $endCell_appname = $sh.cells.item(1,2).EntireColumn.find("").Address() $endCell_appname = [regex]::replace($endCell_appname, '(\$\w+\$)(\d+)', …

Member Avatar
+0 forum 0

Today I have finally made up my mind to quit bat scripting and go for powershell... I need to do a quick script bascially trying to looping through a command output.. can anyone shed some light? i tried foreach ($col in 'app-command -argument') { echo $col } well, guess my guess isn't correct. Can anyone help me with this? Thanks thanks

Member Avatar
+0 forum 0

Well, as you might know, when you are attempting to run a script from poweshell and have not used: Get-ExecutionPolicy You will get File C:\scripts\test.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get- help about_signing" for more details. At line:1 char:19 + c:\scripts\test.ps1 <<<< So i did use this `get-executionpolicy` thing at the end. And i got a lovely message from the console: Restricted So i tried Set-ExecutionPolicy RemoteSigned But then from the console i got another message: Get-ExecutionPolicy : Cannot bind parameter 'Scope'. Cannot convert value "RemoteSigned" to type "Microsoft.PowerShell ExecutionPolicyScope" …

Member Avatar
Member Avatar
+0 forum 5

I am new to Powershell and I am trying to get an understanding of it through borrowing script and making it work for my system. I have a script that I thought would take files from a target folder and zip them into a destination folder. It is creating zip folders in my destination folder based on the names of the files in the target folders, but the zipped folders are empty. How do I get the zipped folders to contain the files from the target folder? I am obviously missing some script or haven't manipulated it enough to work …

Member Avatar
Member Avatar
+0 forum 1

Hello, So I'm attempting to do a bulk creation of users into Active Directory (Server 2008) using Powershell. I have a script but every time it runs it throws a exception error. I have tried to go through and find what is wrong, but I am having little luck. Any help would be greatly appreciated! Script: [CODE] $objOU=[ADSI]“LDAP://OU=Users,DC=notmyrealdchere,DC=com” $list = Import-Csv "userImport.csv" foreach ($dataRecord in $list) { $cn=$dataRecord.FirstName + ” ” + $dataRecord.LastName $sAMAccountName=$dataRecord.FirstName + “.” + $dataRecord.LastName $givenName=$dataRecord.FirstName $surName=$dataRecord.LastName $sAMAccountName=$sAMAccountName.ToLower() $displayName=$surName + “, ” + $givenName $userPrincipalName=$sAMAccountName + “@itas.ca” $objUser=$objOU.Create(“user”,”CN=”+$cn) $objUser.Put(“sAMAccountName”,$sAMAccountName) $objUser.Put(“userPrincipalName”,$userPrincipalName) $objUser.Put(“displayName”,$displayName) $objUser.Put(“givenName”,$givenName) $objUser.Put(“surName”,$surName) $objUser.SetInfo() $objUser.SetPassword(“P@assw0rd”) $objUser.psbase.InvokeSet(“AccountDisabled”,$false) $objUser.SetInfo() …

Member Avatar
+0 forum 0

Hi guys, I want to run the following in a c# loop but I just don't know how to pass a multi value for a parameter with a comma. The actual cmdlet would be below and does work in exchange powershell: Set-CalendarProcessing –ResourceDelegates [email]jonDoe@test.com,johnnydoe@test.com[/email] -identity [email]testroom@test.com[/email] –AutomateProcessing AutoUpdate I know my code connection works but it's the "–ResourceDelegates [email]jonDoe@test.com,johnnydoe@test.com[/email]" I don't know how to pass, shown below: Sample part of the code is here: [CODE] command.AddCommand("Set-CalendarProcessing"); command.AddParameter("-ResourceDelegates", "userA@test.com,userB@test.com"); command.AddParameter("-Identity", "test@test.com"); command.AddParameter("-AutomateProcessing", "AutoUpdate"); [/CODE] Thanks Steve

Member Avatar
Member Avatar
+0 forum 1

hi guys, i'm running a recordset read as below and within that running commands against a 2010 exchange server. i wanted to know what you thnk the fastest method there is of doing this?Is the best mehod to put the connection to the exchange server outside the rdr.read, and then only have the runspace/command in the rdr.read? let me know what you think i'd really appreciate any input, as you can see i'm not expert! [CODE] while (rdr.Read()) { if (exchversion == "2010") { SecureString password = new SecureString(); string str_password = exchpwd; string username = exchuser; string liveIdconnectionUri = …

Member Avatar
Member Avatar
+0 forum 1

The End.