Powershell

19K

Solutions

8K

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 have 35GB Pst I want to import to the existing online archive of for user.

We are using Exchange 2013.

I tried importing it through outlook by it is taking to long.

Is there another way i can use?  Through powershell or any other way.
0
Exploring SQL Server 2016: Fundamentals
LVL 13
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Hi,


I'm looking for a SMTP test tool which:

- Can use TLS connection
- port 587.
- can add username /pw

Any idea where I get a that tool?
0
Hi,

I have lots of jsons which I d need to mass edit (add entries, remove, edit, based upon some logic).  F.e. if entry entry1.date.request is not existing add with value y etc
I d like to to this Powershell based. Also json validation needs to occur (syntax ok).

Maybe there is a tool also as backup/extra checks.

J
0
I need to get list of servers which are shut down in our secondary data center

which powershell should I use or can I find through GUI
0
I have been using Netsh to create a back up text file and Database file(db) and automatically copy the results to a server share as follows:
netsh dhcp server dump > \\Server-IP-Address\Sharename$\dhcpcfg.txt
netsh dhcp server export \\Server-IP-Address\Sharename$\dhcpdb all
pause
This worked great with Server 2008 R2 but is not working with Server 2012 R2. Can you please advise me as what the problem and solution might be or another possibly power shell command that might do the same things with the same output?
1
Hello experts,

The following powershell script allows me to download files from an specific gateway provided by one of my editors:

#login information
$user= ""
#$user= Read-Host "Please enter a value"
#Password
$pass= ""
#$pass= read-host 'Enter Password' -AsSecureString
#ID of service
$IDapi= Read-Host "Please enter service number"
#Setup hmtl file
$api_html = "${IDapi}.html"
#Create folder in which will be located files to download
md ${IDapi}

#Reformat header
$pair = "${user}:${pass}"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }

#Setup url
$url_setup = "https://url/getLog?nb=${IDapi}"

#Display url
$url_setup

#Recover html file (file which contains the various log listing
Invoke-WebRequest -Uri $url_setup -Headers $headers -OutFile .\$IDapi\$api_html

#Cleaning html file and build txt file
findstr.exe "filename" .\$IDapi\$api_html > .\$IDapi\${IDapi}_log.txt
$content = Get-Content ".\$IDapi\${IDapi}_log.txt" | foreach { $_ -replace '" />','' } 
Set-Content -Path ".\$IDapi\${IDapi}_log.txt" -Value $content
$content = Get-Content ".\$IDapi\${IDapi}_log.txt" | foreach { $_ -replace "	","" } 
Set-Content -Path ".\$IDapi\${IDapi}_log.txt" -Value $content
$content = Get-Content ".\$IDapi\${IDapi}_log.txt" | foreach { $_ -replace '<input type="hidden" name="filename" value="','' } 
Set-Content -Path 

Open in new window

1
I have a bash script, and I need to re write it in to powershell.
I am newbie and I am learning but its taking me too long, and I feel that altho I am learning by searching I am losing a lot f time.

attached 3 bash files

&

what I have done so far im ps1
enrollment.sh
mock_server_control.sh
script_helper.sh
EnrollmentTest.ps1
mock_server_control.ps1
script_helper.ps1
0
Is there a PowerShell script or other utility to list all the users under organization tenant that have OneDrive enabled and their usage - i.e. - space used and the folders/files they are backing up?  We have instructed our users to enable local backups (Desktop, Documents, and Pictures folders) and want to ensure they have done so.
0
Hi Experts,

I've been working on this powershell script and need some help with a couple of things.  The script will be called from this vbscript to pass the computername or listofcomputers variables.

What I'd like expertise or help with is:

1. I've tested calling this from the VBScript Code in top comments section, but didn't get the computername variable to pass down.  (this would be done from the vbscript above, but wanted just a test wrapper to test).  EDIT:  If this is too difficult, I'd like to set it up to pull from a list of computers.

2. I'm first running "Test-MyConnection" (if) the computer is online, I'm then calling a executable.exe.  This is the part I'm having issues with - I don't necessarily want to run a .exe here, but call an SCCM advert (pasted below from client center), or, I also have a vbscript that runs the advert I could call out to.  This advert would exist locally on every computer.  The part I'm unsure about, or how to code is having this advert run on each computer in the list of variables


SCCM Advert Code:
 get-wmiobject -query "SELECT * FROM CCM_Scheduler_ScheduledMessage WHERE ScheduledMessageID='SCCM00001-SCCM00002-5D2960FE'" -namespace "ROOT\ccm\policy\machine\actualconfig"
 

Open in new window

0
Exchange 2013 delete deleted items , permanently. via power shell
0
Introduction to R
LVL 13
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

We are trying to implement the Win 10 1809 STIG. Several of the checks in the STIG use Get-ProcessMitigation -Name PROGRAM.  Several checks are failing due to the PS command error below:
Get-ProcessMitigation -Name Acrobat.exe
Get-ProcessMitigation : Requested registry access is not allowed.
At line:1 char:1
+ Get-ProcessMitigation -Name Acrobat.exe
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-ProcessMitigation], SecurityException
    + FullyQualifiedErrorId : System.Security.SecurityException,Microsoft.Samples.PowerShell.Commands.GetProcessMitigationCommand

Open in new window

However, the following runs fine:
Get-ItemProperty -path 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Acrobat.exe'

DisableExceptionChainValidation : 0
MitigationOptions               : {1, 1, 33, 0...}
MitigationAuditOptions          : {0, 0, 0, 0...}
PSPath                          : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Acrobat.exe
PSParentPath                    : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
PSChildName                     : Acrobat.exe
PSDrive                         : HKLM
PSProvider                      : Microsoft.PowerShell.Core\Registry

Open in new window

Get-ProcessMitigation -system also runs fine.  Get-ProcessMitigation without the -name is suppose to return all the program values, however that has the same registry error.  We are having a hard time trying to figure out how to fix this so we can get accurate results.
1
Requirement using powershell :

In CSV file, If there is data in the Column and there is no header than name the column as Temporary Column and If there is no data in the column without header delete it. Check each Row if the whole row is empty delete it.
In header if we see " " replace with "_" and  "#"  replace with "Nm"
Replace the spaces in the filename with "_" and timestamp

Thank you
Delete.PNG
1
need a date for last time updates we’re imported to an offline wsus  (for use in a report script)
ideally powershell. but can’t find a log either (change.log doesn’t show.   and wsusconfig.lastchangedate isn’t showing the date updates were imported
windows 2012 r2

written a report for the people that care about that sort of thing. but would like it to know that the latest months patches are on.
1
PowerShell script to automate SQL Database Failover/Failback test

PowerShell Automation TASK:
1)      Create a PowerShell script to failover SQL Database servers from Primary Site to Data Recovery Site.

2)      Create a second PowerShell script to failback SQL Database servers from Data Recovery Site to Primary Site.

We have two SQL database servers in our Primary Site, one server is setup as primary SQL database server (SQLSER01), and the other one is setup as secondary SQL database server (SQLSER02). The primary server is replicated to the secondary server, the two servers are members of Availability group AG1.

Availability group AG1 (Primary site)
   SQLSER01
   SQLSER02

We have two SQL database servers in our Data Recovery Site, one server is setup as primary SQL database server (SQLSER03), and the other one is setup as secondary SQL database server (SQLSER04). The primary server is replicated to the secondary server, the two servers are members of Availability group AG2.

Availability group AG2 (Data Recovery site)
  SQLSER03
  SQLSER04

DistrAG
  Distributed group is the connection between the two Availability groups (AG1 & AG2).

Failover Process Steps:
1)      Connect to each SQL server in AG1 group in Primary Site, query servers to find out which one is primary database server and which one is secondary database server.

2)      Connect to each SQL server in AG2 group in Data Recovery site, query servers to find out which one is primary database server and …
0
Hello,
I am trying to run a powershell script that runs via sccm task sequencer via "task sequence media" option.
The goal is to recieve user input right after the os installation to change computer name since the step after that is to add that computer to the domain.

After i create the media (USB), i run it and when it reaches the script part i get an error :
sccm-error.jpg
i.e.
if i disable this step , everything else works fine, including adding the pc to the domain - only it recives random name.
0
I have an XML generated out of a stored procedure and stored in a variable in Execute Process task. Scoping at package level.
I am trying to pass that variable on to a power shell script as input to write to an  file with .xml . It executes without any error ,but no file is generated.
Arguments is set through a variable having the following ..

 
   "-ExecutionPolicy ByPass  -command \". '" + @[User::PowerShellScriptFile] + "' " + @[User::XMLFileNamePath] +@[User::XMLOutput]

Open in new window


PowerShellScriptFile --> Power shell file path  
XMLFileNamePath      --> UNC path where file is to be generated

PS file:

   
param ([string]$Filepath , [string]$XMLText)
    
    if (!(Test-Path $Filepath))
    {
       New-Item -path $Filepath -type "file" 
       Add-Content -path $Filepath -value $XMLText
    
       Write-Host "Created new file and text content added"
    }
    else
    { 
      Clear-Content -path $Filepath
      Add-Content -path $Filepath -value $XMLText
    
      Write-Host "File already exists and new text content added"
    }

Open in new window

Please guide me for correct argument value, as I tried with some other options. Following Argument value when run with filepath hard coded in above Ps file ( and removing the params of course) ,does generate file /append the text correctly.  So I guess no permissions issue .

-ExecutionPolicy ByPass -command  ". 'C:\PSCheck\XMLFilegenerate.ps1' Hello"

Open in new window

0
Trying to accomplish the following, oBdA provided me with the process script, but I'd like to build on it.  If anyone can help, it would be greatly appreciated!

Have a powershell script that can be called from a vbscript and pass the parameter defined in the vbscript to the powershell script. In vbscript, I can call with this code, but not sure how to pass the parameter (computer) for example defined in vbscript...
'Set objShell = CreateObject("Wscript.Shell")
'Objshell.Run("powershell.exe -noexit .\test.ps1")

Open in new window

Powershell Script I'd like to do a few things:
• Check if the computer is online or offline.
• if computer is is offline, exit and send an email
• if the computer is online, run the below script that will check for running processes.
• if the below has anything other than return code 0 (meaning process is still running), have send email
• if the below has a return code of 0 (meaning no processing running), run an executable and invoke some SCCM commands.
 $computerName = 'RemoteMachine' ## Set to $null to run locally
$processList = @'
    "Name",             "Expected",     "Running"
    "cmd",              "1",            "0"
    "powershell",       "1",            "0"
    "OfficeClickToRun", "2",            "0"
'@ | ConvertFrom-Csv | ForEach-Object {$_.Expected = [int]$_.Expected; $_}

$splat = @{}
If ($computerName) {
    $splat['ComputerName'] = $computerName
    Write-Host "Testing processes on $($computerName)" -ForegroundColor Yellow

Open in new window

0
Trying to use Net use remotely to find all users mapped drives.  Is this possible?
1
hello IT fellas

I have a question in Windows DHCP server. Which I have many bad address problem in it. So, the question is:
Is there any command in powershell to delete all the bad addresses at once?
1
CompTIA Cloud+
LVL 13
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

HI,

I have 2 folders: Folder1 and Folder2.    I want to check that all files and subfolders in Folder1 got copied to Folder2, by looking at a count of files and file sizes.

In WIndows 10, How do I write a powershell to do this?
0
I'm using WIndows 10.

In Microsoft Windows Explorer, I have 2 folders that I want to compare all the files and subfolders in terms of a count of files and file sizes.

Is there a powershell script that can do this?
0
get output into csv. Get-AzureRmReservationOrderId
0
Hello,

We have rolled out .Net applications to the business in the past and we are looking to uninstall them from every PC.

Is there a way to uninstall .Net Applications and remove all remnants using powershell.

The .Net applications sit under the users local profile, in a unique folder location.
EG: \AppData\Local\Apps\2.0\JY18J8NH.QBT\XJJVCJVAGLDO\wasa..tion_c0eee0d5a63f6a5c_0001.0090_60cd514b981ffa96

Cheers!
0
Dear EE,

We need to create 20 VMs simultaneously on Microsoft Azure from PowerShell.
Can you please help to explain how can we do this from Script.
Appreciated if you please explain Step by Step.
From Market Place and from Image.

Thanks
0
Powershell Enter-PSSession no longer working. Recently I started using the PowerShell command Enter-PSSession to run several commands on some remote PCs.

My workstation runs Windows 10 Pro, and the target computers all run windows 7 Pro this is in a domain environment and I'm doing this with admin credentials. It worked at first, but recently I've started getting an error whenever I try to run the Enter-PSSession command as shown in the attached screenshot.
screenshot of errorother users with the same permissions as myself do not get this message and are able to use Enter-PSSession without trouble.

Is it possible to somehow reset my PowerShell preferences/settings back to default and remove any extra modules I may have installed that could have caused this?
0

Powershell

19K

Solutions

8K

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.